add parse threads
This commit is contained in:
@@ -2,47 +2,45 @@
|
||||
#include <string.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_gpio.h"
|
||||
#include "chrg_rel.h"
|
||||
|
||||
struct chrg_rel_t chrgrel[TOTAL_CHS] = {
|
||||
[IDX_CH_0] = {PIN_NORTH_CH0_P0, PIN_NORTH_CH0_P1, PIN_NORTH_CH0_P2},
|
||||
[IDX_CH_1] = {PIN_NORTH_CH1_P0, PIN_NORTH_CH1_P1, PIN_NORTH_CH1_P2},
|
||||
[IDX_CH_2] = {PIN_NORTH_CH2_P0, PIN_NORTH_CH2_P1, PIN_NORTH_CH2_P2},
|
||||
[IDX_CH_3] = {PIN_NORTH_CH3_P0, PIN_NORTH_CH3_P1, PIN_NORTH_CH3_P2}
|
||||
[IDX_CH_0] = {GPO_PIN_CH1_P0, GPO_PIN_CH1_P1, GPO_PIN_CH1_P2},
|
||||
[IDX_CH_1] = {GPO_PIN_CH2_P0, GPO_PIN_CH2_P1, GPO_PIN_CH2_P2},
|
||||
[IDX_CH_2] = {GPO_PIN_CH3_P0, GPO_PIN_CH3_P1, GPO_PIN_CH3_P2},
|
||||
[IDX_CH_3] = {GPO_PIN_CH4_P0, GPO_PIN_CH4_P1, GPO_PIN_CH4_P2}
|
||||
};
|
||||
|
||||
// 继电器组切换
|
||||
void chrg_north_sw_rel (eIDX_CH ch, eIDX_ID id)
|
||||
// 北向继电器组 组合切换
|
||||
void chrg_nor_sw_rel (eIDX_CH ch, eIDX_ID id)
|
||||
{
|
||||
if (ch >= TOTAL_CHS) {
|
||||
return ;
|
||||
}
|
||||
|
||||
rt_pin_write(chrgrel[ch].p2, PIN_HIGH);
|
||||
|
||||
if (ID_SOURCE == id) {
|
||||
rt_pin_write(chrgrel[ch].p2, PIN_HIGH);
|
||||
rt_pin_write(chrgrel[ch].p0, PIN_LOW);
|
||||
rt_pin_write(chrgrel[ch].p1, PIN_HIGH);
|
||||
} else if (ID_SINK == id) {
|
||||
rt_pin_write(chrgrel[ch].p2, PIN_HIGH);
|
||||
rt_pin_write(chrgrel[ch].p1, PIN_LOW);
|
||||
rt_pin_write(chrgrel[ch].p0, PIN_HIGH);
|
||||
} else {
|
||||
rt_pin_write(chrgrel[ch].p2, PIN_LOW);
|
||||
rt_pin_write(chrgrel[ch].p1, PIN_LOW);
|
||||
rt_pin_write(chrgrel[ch].p0, PIN_LOW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int charg_rel_init (void)
|
||||
static int chrg_nor_rel_init (void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < TOTAL_CHS; i++) {
|
||||
rt_pin_mode(chrgrel[i].p0, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(chrgrel[i].p1, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(chrgrel[i].p2, PIN_MODE_OUTPUT);
|
||||
|
||||
rt_pin_write(chrgrel[i].p2, PIN_HIGH);
|
||||
rt_pin_write(chrgrel[i].p2, PIN_LOW);
|
||||
rt_pin_write(chrgrel[i].p0, PIN_LOW);
|
||||
rt_pin_write(chrgrel[i].p1, PIN_LOW);
|
||||
}
|
||||
@@ -51,7 +49,7 @@ static int charg_rel_init (void)
|
||||
}
|
||||
|
||||
|
||||
INIT_DEVICE_EXPORT(charg_rel_init);
|
||||
INIT_DEVICE_EXPORT(chrg_nor_rel_init);
|
||||
|
||||
#if 1
|
||||
int rel_test (int argc, char **argv)
|
||||
@@ -73,7 +71,7 @@ int rel_test (int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
rt_uint8_t val = (rt_uint8_t)atoi(argv[3]);
|
||||
chrg_north_sw_rel((eIDX_CH)idx, (eIDX_ID)val);
|
||||
chrg_nor_sw_rel((eIDX_CH)idx, (eIDX_ID)val);
|
||||
} else if (strcmp(argv[1], "get") == 0) {
|
||||
rt_uint8_t data[3] = {0};
|
||||
data[0] = rt_pin_read(chrgrel[idx].p0);
|
||||
|
||||
Reference in New Issue
Block a user