Feat(#7): new D0/D1 as 5V function
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
This commit is contained in:
+3
-3
@@ -3,7 +3,7 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 23
|
||||
#define VERSION_DATE_MONTH 6
|
||||
#define VERSION_DATE_DAY 2
|
||||
#define VERSION_DATE_HOUR 11
|
||||
#define VERSION_DATE_MINUTE 1
|
||||
#define VERSION_DATE_DAY 5
|
||||
#define VERSION_DATE_HOUR 14
|
||||
#define VERSION_DATE_MINUTE 47
|
||||
#endif
|
||||
|
||||
+1
-27
@@ -5,6 +5,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "Elite_version.h"
|
||||
#include "driver/timers.h"
|
||||
#include "driver/spi_ctrl.h"
|
||||
#include "module/led_APA_102.h"
|
||||
#include "service/mode_all_output_ctrl.h"
|
||||
@@ -153,34 +154,7 @@ struct wm_aout_ctx_t
|
||||
#define CH_A1 5
|
||||
#define CH_D1 6
|
||||
#define CH_PR1 7
|
||||
struct ch_all_out_ctrl_ctx_t
|
||||
{
|
||||
// user setting
|
||||
uint8_t used: 1,
|
||||
v_early: 1,
|
||||
v_mid: 4,
|
||||
v_late: 1,
|
||||
v_rsvd: 1;
|
||||
uint32_t t_early;
|
||||
uint32_t t_mid[4];
|
||||
uint32_t t_late;
|
||||
uint16_t cycle;
|
||||
|
||||
// automatic setting
|
||||
uint32_t t_part[4];
|
||||
uint32_t t_period;
|
||||
uint8_t init: 1,
|
||||
t_early_period: 1,
|
||||
t_mid_period: 1,
|
||||
t_late_period: 1,
|
||||
rsvd: 4;
|
||||
uint32_t v_scan_rate;
|
||||
};
|
||||
|
||||
struct mode_all_out_ctrl_ctx_t
|
||||
{
|
||||
struct ch_all_out_ctrl_ctx_t channel[8];
|
||||
};
|
||||
|
||||
/**
|
||||
* Latch initialize
|
||||
|
||||
+8
-58
@@ -620,6 +620,8 @@ static void receive_instruction(uint8 *ins)
|
||||
instru.Trig_CurCon[1] = 5000;
|
||||
instru.Trig_CurCon[2] = 5000;
|
||||
instru.Trig_CurCon[3] = 5000;//20mA
|
||||
instru.tri_d0_as_5v_en = 0;
|
||||
instru.tri_d1_as_5v_en = 0;
|
||||
// update_led(LED_WORKING);
|
||||
break;
|
||||
}
|
||||
@@ -759,64 +761,6 @@ static void receive_instruction(uint8 *ins)
|
||||
break;
|
||||
}
|
||||
|
||||
case SET_EN_CHAN_DEV_TEST: { // 0x0F
|
||||
InitTrigChan();
|
||||
switch (ins[4])
|
||||
{
|
||||
case TRIG_PR: { // 0x00
|
||||
instru.tri_pr0_en = (bool)(ins[5] >> 4);
|
||||
instru.tri_pr1_en = (bool)(ins[5] & 0x0F);
|
||||
TRC.chan_en[0] = instru.tri_pr0_en;
|
||||
TRC.chan_en[7] = instru.tri_pr1_en;
|
||||
break;
|
||||
}
|
||||
case TRIG_MOS_DOUT: { // 0x01
|
||||
instru.tri_d0_en = (bool)(ins[5] >> 4);
|
||||
instru.tri_d1_en = (bool)(ins[5] & 0x0F);
|
||||
TRC.chan_en[1] = instru.tri_d0_en;
|
||||
TRC.chan_en[6] = instru.tri_d1_en;
|
||||
break;
|
||||
}
|
||||
case TRIG_MOS_AOUT: { // 0x02
|
||||
instru.tri_a0_en = (bool)(ins[5] >> 4);
|
||||
instru.tri_a1_en = (bool)(ins[5] & 0x0F);
|
||||
instru.tri_a2_en = (bool)(ins[6] >> 4);
|
||||
instru.tri_a3_en = (bool)(ins[6] & 0x0F);
|
||||
TRC.chan_en[2] = instru.tri_a0_en;
|
||||
TRC.chan_en[3] = instru.tri_a2_en;
|
||||
TRC.chan_en[4] = instru.tri_a3_en;
|
||||
TRC.chan_en[5] = instru.tri_a1_en;
|
||||
break;
|
||||
}
|
||||
case TRIG_5V_OUT: { // 0x03
|
||||
instru.tri_d0_as_5v_en = (bool)(ins[5] >> 4);
|
||||
instru.tri_d1_as_5v_en = (bool)(ins[5] & 0x0F);
|
||||
TRC.chan_en[8] = instru.tri_d0_as_5v_en;
|
||||
TRC.chan_en[9] = instru.tri_d1_as_5v_en;
|
||||
break;
|
||||
}
|
||||
case TRIG_input: {
|
||||
// TRIG_TrigEnable = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!instru.tri_d0_as_5v_en)
|
||||
{ // if 5V enable, auto disable DOUT
|
||||
instru.tri_d0_en = 0;
|
||||
TRC.chan_en[1] = instru.tri_d0_en;
|
||||
}
|
||||
if (!instru.tri_d1_as_5v_en)
|
||||
{
|
||||
instru.tri_d1_en = 0;
|
||||
TRC.chan_en[6] = instru.tri_d1_en;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case AOUT_DEV_TEST: { // 0x05
|
||||
uint16_t TW1508in = 0;
|
||||
|
||||
@@ -1031,6 +975,12 @@ static void receive_instruction(uint8 *ins)
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x35: { // 0x35 3000FF 35???? 350101
|
||||
instru.tri_d0_as_5v_en = ins[4];
|
||||
instru.tri_d1_as_5v_en = ins[5];
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+127
-44
@@ -1,70 +1,153 @@
|
||||
#include <stdint.h>
|
||||
#include "service/mode_all_output_ctrl.h"
|
||||
|
||||
//MODE_ALL_OUTPUT_CTRL
|
||||
void __all_output_ctrl_mode_ch_vsan(struct ch_all_out_ctrl_ctx_t *pr0, uint32_t delta_t, uint8_t ch)
|
||||
struct ch_all_out_ctrl_ctx_t
|
||||
{
|
||||
// user setting
|
||||
uint8_t used: 1,
|
||||
v_early: 1,
|
||||
v_mid: 4,
|
||||
v_late: 1,
|
||||
v_rsvd: 1;
|
||||
uint32_t t_early;
|
||||
uint32_t t_mid[4];
|
||||
uint32_t t_late;
|
||||
uint16_t cycle;
|
||||
|
||||
// automatic setting
|
||||
uint32_t t_part[4];
|
||||
uint32_t t_period;
|
||||
uint8_t init: 1,
|
||||
t_early_period: 1,
|
||||
t_mid_period: 1,
|
||||
t_late_period: 1,
|
||||
rsvd: 4;
|
||||
uint32_t v_scan_rate;
|
||||
};
|
||||
|
||||
struct mode_all_out_ctrl_ctx_t
|
||||
{
|
||||
struct ch_all_out_ctrl_ctx_t channel[8];
|
||||
};
|
||||
|
||||
void __all_output_ctrl_mode_ch_vsan(struct ch_all_out_ctrl_ctx_t *channel, uint32_t delta_t, uint8_t ch)
|
||||
{
|
||||
uint32_t m;
|
||||
|
||||
if (pr0->init) {
|
||||
pr0->v_scan_rate = 0;
|
||||
pr0->init = false;
|
||||
if (!channel->used)
|
||||
return;
|
||||
|
||||
if (channel->init) {
|
||||
channel->v_scan_rate = 0;
|
||||
channel->init = false;
|
||||
}
|
||||
|
||||
pr0->v_scan_rate += delta_t;
|
||||
channel->v_scan_rate += delta_t;
|
||||
|
||||
if (ch==CH_PR0)
|
||||
notify_ch1 = (int32_t)pr0->v_scan_rate;
|
||||
if (channel->t_early_period) {
|
||||
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) {
|
||||
if(channel->v_early) {
|
||||
TRC.chan_en[CH_D0] = 0;
|
||||
TRC.chan_en[8] = 0;
|
||||
} else {
|
||||
TRC.chan_en[CH_D0] = 0;
|
||||
TRC.chan_en[8] = 1;
|
||||
}
|
||||
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
|
||||
if(channel->v_early) {
|
||||
TRC.chan_en[CH_D1] = 0;
|
||||
TRC.chan_en[9] = 0;
|
||||
} else {
|
||||
TRC.chan_en[CH_D1] = 0;
|
||||
TRC.chan_en[9] = 1;
|
||||
}
|
||||
} else {
|
||||
TRC.chan_en[ch] = channel->v_early;
|
||||
}
|
||||
|
||||
if (pr0->t_early_period) {
|
||||
TRC.chan_en[ch] = pr0->v_early;
|
||||
if (pr0->v_scan_rate >= pr0->t_early) {
|
||||
pr0->v_scan_rate -= pr0->t_early; //To get right time
|
||||
pr0->t_early_period = false;
|
||||
pr0->t_mid_period = true;
|
||||
pr0->v_scan_rate = 0;
|
||||
if (channel->v_scan_rate >= channel->t_early) {
|
||||
channel->v_scan_rate -= channel->t_early; //To get right time
|
||||
channel->t_early_period = false;
|
||||
channel->t_mid_period = true;
|
||||
channel->v_scan_rate = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (pr0->t_mid_period) {
|
||||
if (pr0->v_scan_rate >= pr0->t_period) {
|
||||
pr0->v_scan_rate -= pr0->t_period; //To get right time
|
||||
pr0->cycle--;
|
||||
if (pr0->cycle == 0) {
|
||||
pr0->t_mid_period = false;
|
||||
pr0->t_late_period = true;
|
||||
pr0->v_scan_rate = 0;
|
||||
if (channel->t_mid_period) {
|
||||
if (channel->v_scan_rate >= channel->t_period) {
|
||||
channel->v_scan_rate -= channel->t_period; //To get right time
|
||||
channel->cycle--;
|
||||
if (channel->cycle == 0) {
|
||||
channel->t_mid_period = false;
|
||||
channel->t_late_period = true;
|
||||
channel->v_scan_rate = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m = pr0->v_scan_rate ? (pr0->v_scan_rate % pr0->t_period) : 0;
|
||||
m = channel->v_scan_rate ? (channel->v_scan_rate % channel->t_period) : 0;
|
||||
|
||||
for(int i=0; i<4; i++) {
|
||||
if (m < pr0->t_part[i]) {
|
||||
TRC.chan_en[ch] = (pr0->v_mid) & (1 << i);
|
||||
if (ch==CH_PR0)
|
||||
notify_ch2 = (int32_t)TRC.chan_en[ch];
|
||||
else if (ch==CH_D0)
|
||||
notify_ch3 = (int32_t)TRC.chan_en[ch];
|
||||
else if (ch==CH_A0)
|
||||
notify_ch4 = (int32_t)TRC.chan_en[ch];
|
||||
else if (ch==CH_A2)
|
||||
notify_ch5 = (int32_t)TRC.chan_en[ch];
|
||||
else if (ch==CH_PR1)
|
||||
notify_ch6 = (int32_t)TRC.chan_en[ch];
|
||||
if (m < channel->t_part[i]) {
|
||||
if (ch == CH_D0 && instru.tri_d0_as_5v_en==1) {
|
||||
if(channel->v_mid & (1 << i)) {
|
||||
TRC.chan_en[CH_D0] = 0;
|
||||
TRC.chan_en[8] = 0;
|
||||
} else {
|
||||
TRC.chan_en[CH_D0] = 0;
|
||||
TRC.chan_en[8] = 1;
|
||||
}
|
||||
} else if (ch == CH_D1 && instru.tri_d1_as_5v_en==1) {
|
||||
if(channel->v_mid & (1 << i)) {
|
||||
TRC.chan_en[CH_D1] = 0;
|
||||
TRC.chan_en[9] = 0;
|
||||
} else {
|
||||
TRC.chan_en[CH_D1] = 0;
|
||||
TRC.chan_en[9] = 1;
|
||||
}
|
||||
} else {
|
||||
TRC.chan_en[ch] = channel->v_mid & (1 << i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (pr0->t_late_period) {
|
||||
TRC.chan_en[ch] = pr0->v_late;
|
||||
if (pr0->v_scan_rate >= pr0->t_late) {
|
||||
pr0->v_scan_rate -= pr0->t_late; //To get right time
|
||||
pr0->used = false;
|
||||
if (channel->t_late_period) {
|
||||
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) {
|
||||
if(channel->v_late) {
|
||||
TRC.chan_en[CH_D0] = 0;
|
||||
TRC.chan_en[8] = 0;
|
||||
} else {
|
||||
TRC.chan_en[CH_D0] = 0;
|
||||
TRC.chan_en[8] = 1;
|
||||
}
|
||||
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
|
||||
if(channel->v_late) {
|
||||
TRC.chan_en[CH_D1] = 0;
|
||||
TRC.chan_en[9] = 0;
|
||||
} else {
|
||||
TRC.chan_en[CH_D1] = 0;
|
||||
TRC.chan_en[9] = 1;
|
||||
}
|
||||
} else {
|
||||
TRC.chan_en[ch] = channel->v_late;
|
||||
}
|
||||
|
||||
if (channel->v_scan_rate >= channel->t_late) {
|
||||
channel->v_scan_rate -= channel->t_late; //To get right time
|
||||
channel->used = false;
|
||||
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) { //ending
|
||||
TRC.chan_en[CH_D0] = 0;
|
||||
TRC.chan_en[8] = 1;
|
||||
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
|
||||
TRC.chan_en[CH_D1] = 0;
|
||||
TRC.chan_en[9] = 1;
|
||||
} else {
|
||||
TRC.chan_en[ch] = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -113,12 +196,12 @@ int all_output_ctrl_mode_create(void)
|
||||
ch->used = true;
|
||||
ch->t_early = 10000;
|
||||
ch->v_early = 1;
|
||||
ch->t_mid[0] = 10000;
|
||||
ch->t_mid[0] = 50000;
|
||||
ch->t_mid[1] = 20000;
|
||||
ch->t_mid[2] = 10000;
|
||||
ch->t_mid[2] = 50000;
|
||||
ch->t_mid[3] = 20000;
|
||||
ch->v_mid = 0b00000101; // |rsvd|v3|v2|v1|v0|
|
||||
ch->cycle = 5;
|
||||
ch->cycle = 3;
|
||||
ch->t_late = 10000;
|
||||
ch->v_late = 1;
|
||||
|
||||
|
||||
-1
@@ -572,7 +572,6 @@ static void SimpleBLEPeripheral_init(void)
|
||||
}
|
||||
|
||||
/*elite code*/
|
||||
#include "driver/timers.h"
|
||||
#include "service/app_ser.h"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user