add parse threads
This commit is contained in:
@@ -49,7 +49,7 @@ static int chrg_clk_init (void)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
INIT_APP_EXPORT(chrg_clk_init);
|
||||
INIT_ENV_EXPORT(chrg_clk_init);
|
||||
|
||||
|
||||
int uptime (void)
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_gpio.h"
|
||||
|
||||
|
||||
struct chrg_io_t chrgios[TOTAL_IOS] = {
|
||||
[IDX_GPO_LED1] = {GPO_PIN_LED1, PIN_MODE_OUTPUT, PIN_HIGH},
|
||||
[IDX_GPO_LED2] = {GPO_PIN_LED2, PIN_MODE_OUTPUT, PIN_HIGH},
|
||||
[IDX_GPO_LED3] = {GPO_PIN_LED3, PIN_MODE_OUTPUT, PIN_HIGH},
|
||||
[IDX_GPO_UART_SW1] = {GPO_PIN_UART_SW1, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_UART_SW2] = {GPO_PIN_UART_SW2, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_UART_SW3] = {GPO_PIN_UART_SW3, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_UART_SW4] = {GPO_PIN_UART_SW4, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH1_P0] = {GPO_PIN_CH1_P0, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH1_P1] = {GPO_PIN_CH1_P1, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH1_P2] = {GPO_PIN_CH1_P2, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH2_P0] = {GPO_PIN_CH2_P0, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH2_P1] = {GPO_PIN_CH2_P1, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH2_P2] = {GPO_PIN_CH2_P2, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH3_P0] = {GPO_PIN_CH3_P0, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH3_P1] = {GPO_PIN_CH3_P1, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH3_P2] = {GPO_PIN_CH3_P2, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH4_P0] = {GPO_PIN_CH4_P0, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH4_P1] = {GPO_PIN_CH4_P1, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_CH4_P2] = {GPO_PIN_CH4_P2, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_NOR_SW_A] = {GPO_PIN_NOR_SW_A, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_NOR_SW_B] = {GPO_PIN_NOR_SW_B, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_SOU_SW_LV1_A] = {GPO_PIN_SOU_SW_LV1_A, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_SOU_SW_LV1_B] = {GPO_PIN_SOU_SW_LV1_B, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_SOU_SW_LV2_A1] = {GPO_PIN_SOU_SW_LV2_A1, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_SOU_SW_LV2_B1] = {GPO_PIN_SOU_SW_LV2_B1, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_SOU_SW_LV2_A2] = {GPO_PIN_SOU_SW_LV2_A2, PIN_MODE_OUTPUT, PIN_LOW},
|
||||
[IDX_GPO_SOU_SW_LV2_B2] = {GPO_PIN_SOU_SW_LV2_B2, PIN_MODE_OUTPUT, PIN_LOW}
|
||||
};
|
||||
|
||||
|
||||
static int chrg_gpios_init (void)
|
||||
{
|
||||
int i = 0;
|
||||
struct chrg_io_t *pIO = RT_NULL;
|
||||
|
||||
for (i = 0; i < TOTAL_IOS; i++) {
|
||||
pIO = &chrgios[i];
|
||||
rt_pin_mode(pIO->base, pIO->mode);
|
||||
if (PIN_MODE_OUTPUT == pIO->mode) {
|
||||
rt_pin_write(pIO->base, pIO->value);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INIT_ENV_EXPORT(chrg_gpios_init);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
#ifndef __CHRG_GPIO_H__
|
||||
#define __CHRG_GPIO_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include <drv_gpio.h>
|
||||
|
||||
// LED 灯脚
|
||||
#define GPO_PIN_LED1 GET_PIN(C, 13) // LED1
|
||||
#define GPO_PIN_LED2 GET_PIN(C, 14) // LED2
|
||||
#define GPO_PIN_LED3 GET_PIN(C, 15) // LED3
|
||||
|
||||
// 北向 source/sink 通信口选通
|
||||
#define GPO_PIN_UART_SW1 GET_PIN(C, 0) // 通道1组
|
||||
#define GPO_PIN_UART_SW2 GET_PIN(A, 0) // 通道2组
|
||||
#define GPO_PIN_UART_SW3 GET_PIN(A, 6) // 通道3组
|
||||
#define GPO_PIN_UART_SW4 GET_PIN(B, 12) // 通道4组
|
||||
|
||||
// 北向继电器1组
|
||||
#define GPO_PIN_CH1_P0 GET_PIN(C, 3) // P0 connect K1/K3 for sink
|
||||
#define GPO_PIN_CH1_P1 GET_PIN(C, 2) // P1 connect K2/K4 for source
|
||||
#define GPO_PIN_CH1_P2 GET_PIN(C, 1) // P2 connect K5 for GND/PGND
|
||||
|
||||
// 北向继电器2组
|
||||
#define GPO_PIN_CH2_P0 GET_PIN(A, 5) // P0
|
||||
#define GPO_PIN_CH2_P1 GET_PIN(A, 4) // P1
|
||||
#define GPO_PIN_CH2_P2 GET_PIN(A, 1) // P2
|
||||
|
||||
// 北向继电器3组
|
||||
#define GPO_PIN_CH3_P0 GET_PIN(C, 5) // P0
|
||||
#define GPO_PIN_CH3_P1 GET_PIN(C, 4) // P1
|
||||
#define GPO_PIN_CH3_P2 GET_PIN(A, 7) // P2
|
||||
|
||||
// 北向继电器4组
|
||||
#define GPO_PIN_CH4_P0 GET_PIN(B, 15) // P0
|
||||
#define GPO_PIN_CH4_P1 GET_PIN(B, 14) // P1
|
||||
#define GPO_PIN_CH4_P2 GET_PIN(B, 13) // P2
|
||||
|
||||
// 北向通信口选通 U14
|
||||
#define GPO_PIN_NOR_SW_A GET_PIN(B, 0)
|
||||
#define GPO_PIN_NOR_SW_B GET_PIN(B, 1)
|
||||
|
||||
// 南向1级通信口选通 U23
|
||||
#define GPO_PIN_SOU_SW_LV1_A GET_PIN(C, 8)
|
||||
#define GPO_PIN_SOU_SW_LV1_B GET_PIN(C, 9)
|
||||
|
||||
// 南向2级通信口选通 左半 U24
|
||||
#define GPO_PIN_SOU_SW_LV2_A1 GET_PIN(A, 15)
|
||||
#define GPO_PIN_SOU_SW_LV2_B1 GET_PIN(C, 10)
|
||||
|
||||
// 南向2级通信口选通 右半 U25
|
||||
#define GPO_PIN_SOU_SW_LV2_A2 GET_PIN(C, 11)
|
||||
#define GPO_PIN_SOU_SW_LV2_B2 GET_PIN(C, 12)
|
||||
|
||||
typedef enum {
|
||||
IDX_GPO_LED1 = 0, // 绿灯
|
||||
IDX_GPO_LED2,
|
||||
IDX_GPO_LED3,
|
||||
|
||||
IDX_GPO_UART_SW1, // source/sink U1 A
|
||||
IDX_GPO_UART_SW2, // source/sink U12 A
|
||||
IDX_GPO_UART_SW3, // source/sink U23 A
|
||||
IDX_GPO_UART_SW4, // source/sink U34 A
|
||||
|
||||
IDX_GPO_CH1_P0, // 继电器1组 K1/K3
|
||||
IDX_GPO_CH1_P1, // 继电器1组 K2/K4
|
||||
IDX_GPO_CH1_P2, // 继电器1组 K5
|
||||
|
||||
IDX_GPO_CH2_P0, // 继电器2组 K1/K3
|
||||
IDX_GPO_CH2_P1, // 继电器2组 K2/K4
|
||||
IDX_GPO_CH2_P2, // 继电器2组 K5
|
||||
|
||||
IDX_GPO_CH3_P0, // 继电器3组 K1/K3
|
||||
IDX_GPO_CH3_P1, // 继电器3组 K2/K4
|
||||
IDX_GPO_CH3_P2, // 继电器3组 K5
|
||||
|
||||
IDX_GPO_CH4_P0, // 继电器4组 K1/K3
|
||||
IDX_GPO_CH4_P1, // 继电器4组 K2/K4
|
||||
IDX_GPO_CH4_P2, // 继电器4组 K5
|
||||
|
||||
IDX_GPO_NOR_SW_A, // U14 北向A
|
||||
IDX_GPO_NOR_SW_B, // U14 北向B
|
||||
|
||||
IDX_GPO_SOU_SW_LV1_A, // U23 南向1级A
|
||||
IDX_GPO_SOU_SW_LV1_B, // U23 南向1级B
|
||||
IDX_GPO_SOU_SW_LV2_A1, // U24 南向2级左A
|
||||
IDX_GPO_SOU_SW_LV2_B1, // U24 南向2级左B
|
||||
IDX_GPO_SOU_SW_LV2_A2, // U25 南向2级右A
|
||||
IDX_GPO_SOU_SW_LV2_B2, // U25 南向2级右B
|
||||
|
||||
TOTAL_IOS
|
||||
} eIDX_IO;
|
||||
|
||||
|
||||
struct chrg_io_t {
|
||||
rt_base_t base; // 管脚号
|
||||
rt_ssize_t mode; // 方向 输出/输入
|
||||
rt_uint8_t value; // 当前值 (输入时不配置)
|
||||
};
|
||||
|
||||
extern struct chrg_io_t chrgios[TOTAL_IOS];
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "chrg_led.h"
|
||||
|
||||
#define LOG_TAG "chrg.led"
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_led_t chrgleds[TOTAL_LEDS] = {
|
||||
[IDX_LED1] = {
|
||||
.index = IDX_LED1,
|
||||
.pin_name = PIN_NAME_LED1,
|
||||
.pin_base = PIN_LED1,
|
||||
.pin_mode = PIN_MODE_OUTPUT,
|
||||
.pin_value = PIN_HIGH,
|
||||
.tmr_name = TMR_NAME_LED1,
|
||||
.tmr_fd = RT_NULL,
|
||||
.tmr_stage = PIN_STAGE_IDLE,
|
||||
.tmr_millis_on = PULSE_TIME*8,
|
||||
.tmr_millis_off = PULSE_TIME*8,
|
||||
.tmr_times = 1,
|
||||
.tmr_cnt = 0,
|
||||
} /*,
|
||||
[IDX_LED2] = {
|
||||
.index = IDX_LED2,
|
||||
.pin_name = PIN_NAME_LED2,
|
||||
.pin_base = PIN_LED2,
|
||||
.pin_mode = PIN_MODE_OUTPUT,
|
||||
.pin_value = PIN_HIGH,
|
||||
.tmr_name = TMR_NAME_LED2,
|
||||
.tmr_fd = RT_NULL,
|
||||
.tmr_stage = PIN_STAGE_IDLE,
|
||||
.tmr_millis_on = PULSE_TIME*8,
|
||||
.tmr_millis_off = PULSE_TIME*8,
|
||||
.tmr_times = 1,
|
||||
.tmr_cnt = 0,
|
||||
},
|
||||
[IDX_LED3] = {
|
||||
.index = IDX_LED3,
|
||||
.pin_name = PIN_NAME_LED3,
|
||||
.pin_base = PIN_LED3,
|
||||
.pin_mode = PIN_MODE_OUTPUT,
|
||||
.pin_value = PIN_HIGH,
|
||||
.tmr_name = TMR_NAME_LED3,
|
||||
.tmr_fd = RT_NULL,
|
||||
.tmr_stage = PIN_STAGE_IDLE,
|
||||
.tmr_millis_on = PULSE_TIME*8,
|
||||
.tmr_millis_off = PULSE_TIME*8,
|
||||
.tmr_times = 1,
|
||||
.tmr_cnt = 0,
|
||||
}*/
|
||||
};
|
||||
|
||||
rt_int32_t chrg_led_get (eIDX_LED index)
|
||||
{
|
||||
if (index >= TOTAL_LEDS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct chrg_led_t *pLED = &chrgleds[index];
|
||||
pLED->pin_value = rt_pin_read(pLED->pin_base);
|
||||
|
||||
return pLED->pin_value;
|
||||
}
|
||||
|
||||
rt_int32_t chrg_led_set (struct chrg_led_t *pLED, rt_uint8_t value)
|
||||
{
|
||||
pLED->pin_value = value;
|
||||
rt_pin_write(pLED->pin_base, pLED->pin_value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
rt_int32_t chrg_led_toggle (eIDX_LED index)
|
||||
{
|
||||
if (index >= TOTAL_LEDS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct chrg_led_t *pLED = &chrgleds[index];
|
||||
pLED->pin_value = !pLED->pin_value;
|
||||
|
||||
rt_pin_write(pLED->pin_base, pLED->pin_value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_int32_t chrg_led_timer_set_on (struct chrg_led_t *pLED)
|
||||
{
|
||||
return rt_timer_control(pLED->tmr_fd, RT_TIMER_CTRL_SET_TIME, (void *)&pLED->tmr_millis_on);
|
||||
}
|
||||
|
||||
static rt_int32_t chrg_led_timer_set_off (struct chrg_led_t *pLED)
|
||||
{
|
||||
return rt_timer_control(pLED->tmr_fd, RT_TIMER_CTRL_SET_TIME, (void *)&pLED->tmr_millis_off);
|
||||
}
|
||||
|
||||
rt_int32_t chrg_led_pulsing (struct chrg_led_t *pLED, rt_uint8_t state)
|
||||
{
|
||||
rt_int32_t ret = 0;
|
||||
|
||||
if (state == PULSE_OFF) {
|
||||
pLED->tmr_stage = PIN_STAGE_IDLE;
|
||||
chrg_led_set(pLED, PIN_HIGH);
|
||||
} else {
|
||||
if (pLED->tmr_millis_on == HOLD_ZERO) { // 常低
|
||||
pLED->tmr_stage = PIN_STAGE_IDLE;
|
||||
rt_timer_stop(pLED->tmr_fd);
|
||||
chrg_led_set(pLED, PIN_HIGH);
|
||||
} else if (pLED->tmr_millis_off == HOLD_ZERO) { // 常高
|
||||
pLED->tmr_stage = PIN_STAGE_IDLE;
|
||||
chrg_led_set(pLED, PIN_LOW);
|
||||
} else { // 交替
|
||||
if (pLED->tmr_stage == PIN_STAGE_IDLE) {
|
||||
pLED->tmr_stage = PIN_STAGE_ON;
|
||||
chrg_led_set(pLED, PIN_LOW);
|
||||
chrg_led_timer_set_on(pLED);
|
||||
ret = rt_timer_start(pLED->tmr_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void chrg_led_timer_timeout_callback (void* parameter)
|
||||
{
|
||||
struct chrg_led_t *pLED = (struct chrg_led_t *)parameter;
|
||||
|
||||
if (pLED->tmr_stage == PIN_STAGE_ON) {
|
||||
pLED->tmr_stage = PIN_STAGE_OFF;
|
||||
|
||||
chrg_led_set(pLED, PIN_HIGH);
|
||||
chrg_led_timer_set_off(pLED);
|
||||
rt_timer_start(pLED->tmr_fd);
|
||||
} else if (pLED->tmr_stage == PIN_STAGE_OFF) {
|
||||
pLED->tmr_stage = PIN_STAGE_IDLE;
|
||||
|
||||
if ((pLED->tmr_times == TIMES_ALWAYS)&&(pLED->tmr_millis_off != HOLD_ZERO)) { // 保持闪烁
|
||||
pLED->tmr_stage = PIN_STAGE_ON;
|
||||
chrg_led_set(pLED, PIN_LOW);
|
||||
chrg_led_timer_set_on(pLED);
|
||||
rt_timer_start(pLED->tmr_fd);
|
||||
} else { // 计数闪烁
|
||||
if (++pLED->tmr_cnt >= pLED->tmr_times) {
|
||||
pLED->tmr_cnt = 0;
|
||||
rt_timer_stop(pLED->tmr_fd);
|
||||
} else {
|
||||
pLED->tmr_stage = PIN_STAGE_ON;
|
||||
chrg_led_set(pLED, PIN_LOW);
|
||||
chrg_led_timer_set_on(pLED);
|
||||
rt_timer_start(pLED->tmr_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static rt_int32_t chrg_led_timer_start (eIDX_LED index)
|
||||
{
|
||||
if (index >= TOTAL_LEDS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct chrg_led_t *pLED = RT_NULL;
|
||||
|
||||
pLED = &chrgleds[index];
|
||||
|
||||
pLED->tmr_fd = rt_timer_create(pLED->tmr_name, chrg_led_timer_timeout_callback,
|
||||
pLED, pLED->tmr_millis_on, RT_TIMER_FLAG_ONE_SHOT);
|
||||
|
||||
if (pLED->tmr_fd == RT_NULL) {
|
||||
LOG_E("tmr create '%s' failed.", pLED->tmr_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
rt_int32_t chrg_led_timer_delete (eIDX_LED index)
|
||||
{
|
||||
if (index >= TOTAL_LEDS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return rt_timer_delete(chrgleds[index].tmr_fd);
|
||||
}
|
||||
|
||||
static rt_int32_t chrg_led_show (struct chrg_led_t *pLED, rt_uint32_t times, rt_uint32_t on, rt_uint32_t off)
|
||||
{
|
||||
rt_int32_t ret = 0;
|
||||
|
||||
pLED->tmr_millis_on = on;
|
||||
pLED->tmr_millis_off = off;
|
||||
pLED->tmr_times = times;
|
||||
pLED->tmr_cnt = 0;
|
||||
|
||||
if (pLED->tmr_millis_on == HOLD_ZERO) {
|
||||
ret = chrg_led_pulsing(pLED, PULSE_OFF);
|
||||
} else {
|
||||
ret = chrg_led_pulsing(pLED, PULSE_ON);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
rt_int32_t chrg_led_flashing (eIDX_LED index, rt_uint32_t times, rt_uint32_t on, rt_uint32_t off)
|
||||
{
|
||||
rt_int32_t ret = -1;
|
||||
struct chrg_led_t *pLED = NULL;
|
||||
|
||||
if (index < TOTAL_LEDS) {
|
||||
pLED = &chrgleds[index];
|
||||
ret = chrg_led_show(pLED, times, on, off);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int chrg_leds_init (void)
|
||||
{
|
||||
rt_uint8_t i = 0;
|
||||
struct chrg_led_t *pLED = RT_NULL;
|
||||
|
||||
for (i = 0; i < TOTAL_LEDS; i++) {
|
||||
pLED = &chrgleds[i];
|
||||
|
||||
rt_pin_mode(pLED->pin_base, pLED->pin_mode);
|
||||
|
||||
if (pLED->pin_mode == PIN_MODE_OUTPUT) {
|
||||
pLED->pin_value = PIN_HIGH;
|
||||
rt_pin_write(pLED->pin_base, pLED->pin_value);
|
||||
}
|
||||
|
||||
chrg_led_timer_start((eIDX_LED)i);
|
||||
}
|
||||
|
||||
chrg_led_flashing(IDX_LED1, TIMES_ALWAYS, PULSE_TIME*8, PULSE_TIME*8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_ENV_EXPORT(chrg_leds_init);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#ifndef __CHRG_PIN_H__
|
||||
#define __CHRG_PIN_H__
|
||||
#ifndef __CHRG_LED_H__
|
||||
#define __CHRG_LED_H__
|
||||
|
||||
#include <rttypes.h>
|
||||
#include <rtdef.h>
|
||||
#include "drv_gpio.h"
|
||||
|
||||
#include "chrg_gpio.h"
|
||||
|
||||
|
||||
#define PIN_NAME_LED1 "led1"
|
||||
@@ -14,9 +15,9 @@
|
||||
#define TMR_NAME_LED2 "tmr_led2"
|
||||
#define TMR_NAME_LED3 "tmr_led3"
|
||||
|
||||
#define PIN_LED1 GET_PIN(C, 13)
|
||||
#define PIN_LED2 GET_PIN(C, 14)
|
||||
#define PIN_LED3 GET_PIN(C, 15)
|
||||
#define PIN_LED1 GPO_PIN_LED1
|
||||
#define PIN_LED2 GPO_PIN_LED2
|
||||
#define PIN_LED3 GPO_PIN_LED3
|
||||
|
||||
#define TIMES_ALWAYS (0) // 无限周期
|
||||
#define TIMES_ONE (1) // 单个周期
|
||||
@@ -30,11 +31,11 @@
|
||||
#define PULSE_TIME (25) // 脉冲动作持续时间,单位 ms
|
||||
|
||||
typedef enum {
|
||||
IDX_PIN_LED1 = 0, // LED1
|
||||
// IDX_PIN_LED2 = 1, // LED2
|
||||
// IDX_PIN_LED3 = 2, // LED3
|
||||
TOTAL_PINS
|
||||
} eIDX_PIN;
|
||||
IDX_LED1 = 0, // LED1
|
||||
// IDX_LED2, // LED2
|
||||
// IDX_LED3, // LED3
|
||||
TOTAL_LEDS
|
||||
} eIDX_LED;
|
||||
|
||||
typedef enum {
|
||||
PIN_STAGE_IDLE = (0x00), // 空闲
|
||||
@@ -44,11 +45,11 @@ typedef enum {
|
||||
PIN_STAGE_END
|
||||
} ePIN_STAGE;
|
||||
|
||||
struct chrg_pin_t {
|
||||
struct chrg_led_t {
|
||||
rt_uint8_t index; // 引脚索引
|
||||
char *pin_name; // 引脚名
|
||||
rt_int32_t pin_base; // 引脚映射值
|
||||
rt_int32_t pin_value; // 引脚值
|
||||
rt_base_t pin_base; // 引脚映射值
|
||||
rt_ssize_t pin_value; // 引脚值
|
||||
rt_uint8_t pin_mode; // 引脚控制方向 0:out 1:in
|
||||
|
||||
const char *tmr_name; // 定时器名
|
||||
@@ -60,15 +61,15 @@ struct chrg_pin_t {
|
||||
rt_uint32_t tmr_cnt; // 定时器已执行周期次数
|
||||
};
|
||||
|
||||
extern struct chrg_pin_t tmrpins[TOTAL_PINS];
|
||||
extern struct chrg_led_t chrgleds[TOTAL_LEDS];
|
||||
|
||||
extern rt_int32_t chrg_pin_set (struct chrg_pin_t *pPIN, rt_uint8_t value);
|
||||
extern rt_int32_t chrg_led_set (struct chrg_led_t *pPIN, rt_uint8_t value);
|
||||
|
||||
extern rt_int32_t chrg_pin_toggle (eIDX_PIN index);
|
||||
extern rt_int32_t chrg_led_toggle (eIDX_LED index);
|
||||
|
||||
extern rt_int32_t chrg_pin_pulsing (struct chrg_pin_t *pPIN, rt_uint8_t state);
|
||||
extern rt_int32_t chrg_led_pulsing (struct chrg_led_t *pPIN, rt_uint8_t state);
|
||||
|
||||
extern rt_int32_t chrg_led_flashing (eIDX_PIN index, rt_uint32_t times, rt_uint32_t on, rt_uint32_t off);
|
||||
extern rt_int32_t chrg_led_flashing (eIDX_LED index, rt_uint32_t times, rt_uint32_t on, rt_uint32_t off);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,247 +0,0 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "chrg_pin.h"
|
||||
|
||||
#define LOG_TAG "chrg.pin"
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_pin_t chrgpins[TOTAL_PINS] = {
|
||||
[IDX_PIN_LED1] = {
|
||||
.index = IDX_PIN_LED1,
|
||||
.pin_name = PIN_NAME_LED1,
|
||||
.pin_base = PIN_LED1,
|
||||
.pin_mode = PIN_MODE_OUTPUT,
|
||||
.pin_value = PIN_HIGH,
|
||||
.tmr_name = TMR_NAME_LED1,
|
||||
.tmr_fd = RT_NULL,
|
||||
.tmr_stage = PIN_STAGE_IDLE,
|
||||
.tmr_millis_on = PULSE_TIME*8,
|
||||
.tmr_millis_off = PULSE_TIME*8,
|
||||
.tmr_times = 1,
|
||||
.tmr_cnt = 0,
|
||||
}/*,
|
||||
[IDX_PIN_LED2] = {
|
||||
.index = IDX_PIN_LED2,
|
||||
.pin_name = PIN_NAME_LED2,
|
||||
.pin_base = PIN_LED2,
|
||||
.pin_mode = PIN_MODE_OUTPUT,
|
||||
.pin_value = PIN_HIGH,
|
||||
.tmr_name = TMR_NAME_LED2,
|
||||
.tmr_fd = RT_NULL,
|
||||
.tmr_stage = PIN_STAGE_IDLE,
|
||||
.tmr_millis_on = PULSE_TIME*8,
|
||||
.tmr_millis_off = PULSE_TIME*8,
|
||||
.tmr_times = 1,
|
||||
.tmr_cnt = 0,
|
||||
},
|
||||
[IDX_PIN_LED3] = {
|
||||
.index = IDX_PIN_LED3,
|
||||
.pin_name = PIN_NAME_LED3,
|
||||
.pin_base = PIN_LED3,
|
||||
.pin_mode = PIN_MODE_OUTPUT,
|
||||
.pin_value = PIN_HIGH,
|
||||
.tmr_name = TMR_NAME_LED3,
|
||||
.tmr_fd = RT_NULL,
|
||||
.tmr_stage = PIN_STAGE_IDLE,
|
||||
.tmr_millis_on = PULSE_TIME*8,
|
||||
.tmr_millis_off = PULSE_TIME*8,
|
||||
.tmr_times = 1,
|
||||
.tmr_cnt = 0,
|
||||
}*/
|
||||
};
|
||||
|
||||
rt_int32_t chrg_pin_get (eIDX_PIN index)
|
||||
{
|
||||
if (index >= TOTAL_PINS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct chrg_pin_t *pPIN = &chrgpins[index];
|
||||
pPIN->pin_value = rt_pin_read(pPIN->pin_base);
|
||||
|
||||
return pPIN->pin_value;
|
||||
}
|
||||
|
||||
rt_int32_t chrg_pin_set (struct chrg_pin_t *pPIN, rt_uint8_t value)
|
||||
{
|
||||
pPIN->pin_value = value;
|
||||
rt_pin_write(pPIN->pin_base, pPIN->pin_value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
rt_int32_t chrg_pin_toggle (eIDX_PIN index)
|
||||
{
|
||||
if (index >= TOTAL_PINS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct chrg_pin_t *pPIN = &chrgpins[index];
|
||||
pPIN->pin_value = !pPIN->pin_value;
|
||||
|
||||
rt_pin_write(pPIN->pin_base, pPIN->pin_value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_int32_t chrg_pin_timer_set_on (struct chrg_pin_t *pPIN)
|
||||
{
|
||||
return rt_timer_control(pPIN->tmr_fd, RT_TIMER_CTRL_SET_TIME, (void *)&pPIN->tmr_millis_on);
|
||||
}
|
||||
|
||||
static rt_int32_t chrg_pin_timer_set_off (struct chrg_pin_t *pPIN)
|
||||
{
|
||||
return rt_timer_control(pPIN->tmr_fd, RT_TIMER_CTRL_SET_TIME, (void *)&pPIN->tmr_millis_off);
|
||||
}
|
||||
|
||||
rt_int32_t chrg_pin_pulsing (struct chrg_pin_t *pPIN, rt_uint8_t state)
|
||||
{
|
||||
rt_int32_t ret = 0;
|
||||
|
||||
if (state == PULSE_OFF) {
|
||||
pPIN->tmr_stage = PIN_STAGE_IDLE;
|
||||
chrg_pin_set(pPIN, PIN_HIGH);
|
||||
} else {
|
||||
if (pPIN->tmr_millis_on == HOLD_ZERO) { // 常低
|
||||
pPIN->tmr_stage = PIN_STAGE_IDLE;
|
||||
rt_timer_stop(pPIN->tmr_fd);
|
||||
chrg_pin_set(pPIN, PIN_HIGH);
|
||||
} else if (pPIN->tmr_millis_off == HOLD_ZERO) { // 常高
|
||||
pPIN->tmr_stage = PIN_STAGE_IDLE;
|
||||
chrg_pin_set(pPIN, PIN_LOW);
|
||||
} else { // 交替
|
||||
if (pPIN->tmr_stage == PIN_STAGE_IDLE) {
|
||||
pPIN->tmr_stage = PIN_STAGE_ON;
|
||||
chrg_pin_set(pPIN, PIN_LOW);
|
||||
chrg_pin_timer_set_on(pPIN);
|
||||
ret = rt_timer_start(pPIN->tmr_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void chrg_pin_timer_timeout_callback (void* parameter)
|
||||
{
|
||||
struct chrg_pin_t *pPIN = (struct chrg_pin_t *)parameter;
|
||||
|
||||
if (pPIN->tmr_stage == PIN_STAGE_ON) {
|
||||
pPIN->tmr_stage = PIN_STAGE_OFF;
|
||||
|
||||
chrg_pin_set(pPIN, PIN_HIGH);
|
||||
chrg_pin_timer_set_off(pPIN);
|
||||
rt_timer_start(pPIN->tmr_fd);
|
||||
} else if (pPIN->tmr_stage == PIN_STAGE_OFF) {
|
||||
pPIN->tmr_stage = PIN_STAGE_IDLE;
|
||||
|
||||
if ((pPIN->tmr_times == TIMES_ALWAYS)&&(pPIN->tmr_millis_off != HOLD_ZERO)) { // 保持闪烁
|
||||
pPIN->tmr_stage = PIN_STAGE_ON;
|
||||
chrg_pin_set(pPIN, PIN_LOW);
|
||||
chrg_pin_timer_set_on(pPIN);
|
||||
rt_timer_start(pPIN->tmr_fd);
|
||||
} else { // 计数闪烁
|
||||
if (++pPIN->tmr_cnt >= pPIN->tmr_times) {
|
||||
pPIN->tmr_cnt = 0;
|
||||
rt_timer_stop(pPIN->tmr_fd);
|
||||
} else {
|
||||
pPIN->tmr_stage = PIN_STAGE_ON;
|
||||
chrg_pin_set(pPIN, PIN_LOW);
|
||||
chrg_pin_timer_set_on(pPIN);
|
||||
rt_timer_start(pPIN->tmr_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static rt_int32_t chrg_pin_timer_start (eIDX_PIN index)
|
||||
{
|
||||
if (index >= TOTAL_PINS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct chrg_pin_t *pPIN = RT_NULL;
|
||||
|
||||
pPIN = &chrgpins[index];
|
||||
|
||||
pPIN->tmr_fd = rt_timer_create(pPIN->tmr_name, chrg_pin_timer_timeout_callback,
|
||||
pPIN, pPIN->tmr_millis_on, RT_TIMER_FLAG_ONE_SHOT);
|
||||
|
||||
if (pPIN->tmr_fd == RT_NULL) {
|
||||
LOG_E("tmr create '%s' failed.", pPIN->tmr_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
rt_int32_t chrg_pin_timer_delete (eIDX_PIN index)
|
||||
{
|
||||
if (index >= TOTAL_PINS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return rt_timer_delete(chrgpins[index].tmr_fd);
|
||||
}
|
||||
|
||||
static rt_int32_t chrg_pin_show (struct chrg_pin_t *pPIN, rt_uint32_t times, rt_uint32_t on, rt_uint32_t off)
|
||||
{
|
||||
rt_int32_t ret = 0;
|
||||
|
||||
pPIN->tmr_millis_on = on;
|
||||
pPIN->tmr_millis_off = off;
|
||||
pPIN->tmr_times = times;
|
||||
pPIN->tmr_cnt = 0;
|
||||
|
||||
if (pPIN->tmr_millis_on == HOLD_ZERO) {
|
||||
ret = chrg_pin_pulsing(pPIN, PULSE_OFF);
|
||||
} else {
|
||||
ret = chrg_pin_pulsing(pPIN, PULSE_ON);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
rt_int32_t chrg_led_flashing (eIDX_PIN index, rt_uint32_t times, rt_uint32_t on, rt_uint32_t off)
|
||||
{
|
||||
rt_int32_t ret = -1;
|
||||
struct chrg_pin_t *pPIN = NULL;
|
||||
|
||||
if (index < TOTAL_PINS) {
|
||||
pPIN = &chrgpins[index];
|
||||
ret = chrg_pin_show(pPIN, times, on, off);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int chrg_pins_init (void)
|
||||
{
|
||||
rt_uint8_t i = 0;
|
||||
struct chrg_pin_t *pPIN = RT_NULL;
|
||||
|
||||
for (i = 0; i < TOTAL_PINS; i++) {
|
||||
pPIN = &chrgpins[i];
|
||||
|
||||
rt_pin_mode(pPIN->pin_base, pPIN->pin_mode);
|
||||
|
||||
if (pPIN->pin_mode == PIN_MODE_OUTPUT) {
|
||||
pPIN->pin_value = PIN_HIGH;
|
||||
rt_pin_write(pPIN->pin_base, pPIN->pin_value);
|
||||
}
|
||||
|
||||
chrg_pin_timer_start((eIDX_PIN)i);
|
||||
}
|
||||
|
||||
chrg_led_flashing(IDX_PIN_LED1, TIMES_ALWAYS, PULSE_TIME*8, PULSE_TIME*8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_ENV_EXPORT(chrg_pins_init);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -6,35 +6,15 @@
|
||||
#include "chrg_switch.h"
|
||||
#include "chrg_def.h"
|
||||
|
||||
// 北向1路 继电器
|
||||
#define PIN_NORTH_CH0_P0 GET_PIN(C, 3)
|
||||
#define PIN_NORTH_CH0_P1 GET_PIN(C, 2)
|
||||
#define PIN_NORTH_CH0_P2 GET_PIN(C, 1)
|
||||
|
||||
// 北向2路 继电器
|
||||
#define PIN_NORTH_CH1_P0 GET_PIN(A, 5)
|
||||
#define PIN_NORTH_CH1_P1 GET_PIN(A, 4)
|
||||
#define PIN_NORTH_CH1_P2 GET_PIN(A, 1)
|
||||
|
||||
// 北向3路 继电器
|
||||
#define PIN_NORTH_CH2_P0 GET_PIN(C, 5)
|
||||
#define PIN_NORTH_CH2_P1 GET_PIN(C, 4)
|
||||
#define PIN_NORTH_CH2_P2 GET_PIN(A, 7)
|
||||
|
||||
// 北向4路 继电器
|
||||
#define PIN_NORTH_CH3_P0 GET_PIN(B, 15)
|
||||
#define PIN_NORTH_CH3_P1 GET_PIN(B, 14)
|
||||
#define PIN_NORTH_CH3_P2 GET_PIN(B, 13)
|
||||
|
||||
struct chrg_rel_t {
|
||||
rt_base_t p0; // connect K1/K3 for sink
|
||||
rt_base_t p1; // connect K2/K4 for source
|
||||
rt_base_t p2; // connect K5 for PGND
|
||||
rt_base_t p2; // connect K5 for GND/PGND
|
||||
};
|
||||
|
||||
extern struct chrg_rel_t chrgrel[TOTAL_CHS];
|
||||
|
||||
extern void chrg_north_sw_rel (eIDX_CH ch, eIDX_ID id);
|
||||
extern void chrg_nor_sw_rel (eIDX_CH ch, eIDX_ID id);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "chrg_gpio.h"
|
||||
#include "chrg_switch.h"
|
||||
|
||||
|
||||
@@ -53,47 +54,48 @@ int chrg_switch_north (eIDX_CH ch)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return chrg_switch_ch(PIN_SW_NORTH_A, PIN_SW_NORTH_B, ch);
|
||||
}
|
||||
|
||||
static int chrg_switch_north_pins_init (void)
|
||||
{
|
||||
rt_pin_mode(PIN_SW_NORTH_A, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(PIN_SW_NORTH_B, PIN_MODE_OUTPUT);
|
||||
|
||||
return 0;
|
||||
return chrg_switch_ch(chrgios[IDX_GPO_NOR_SW_A].base,
|
||||
chrgios[IDX_GPO_NOR_SW_B].base, ch);
|
||||
}
|
||||
|
||||
// 南向1级选通
|
||||
int chrg_switch_south_lv1 (eIDX_CH ch)
|
||||
{
|
||||
if (ch >= 2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return chrg_switch_ch(PIN_SW_SOUTH_LV1_A, PIN_SW_SOUTH_LV1_B, ch);
|
||||
return chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV1_A].base,
|
||||
chrgios[IDX_GPO_SOU_SW_LV1_B].base, ch);
|
||||
}
|
||||
|
||||
// 南向2级左半
|
||||
int chrg_switch_south_lv2_1 (eIDX_CH ch)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (IDX_CH_0 == ch) {
|
||||
ret = chrg_switch_ch(PIN_SW_SOUTH_LV2_A1, PIN_SW_SOUTH_LV2_B1, IDX_CH_2);
|
||||
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A1].base,
|
||||
chrgios[IDX_GPO_SOU_SW_LV2_B1].base, IDX_CH_2);
|
||||
} else if (IDX_CH_1 == ch) {
|
||||
ret = chrg_switch_ch(PIN_SW_SOUTH_LV2_A1, PIN_SW_SOUTH_LV2_B1, IDX_CH_0);
|
||||
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A1].base,
|
||||
chrgios[IDX_GPO_SOU_SW_LV2_B1].base, IDX_CH_0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 南向2级右半
|
||||
int chrg_switch_south_lv2_2 (eIDX_CH ch)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (IDX_CH_0 == ch) {
|
||||
ret = chrg_switch_ch(PIN_SW_SOUTH_LV2_A2, PIN_SW_SOUTH_LV2_B2, IDX_CH_2);
|
||||
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A2].base,
|
||||
chrgios[IDX_GPO_SOU_SW_LV2_B2].base, IDX_CH_2);
|
||||
} else if (IDX_CH_1 == ch) {
|
||||
ret = chrg_switch_ch(PIN_SW_SOUTH_LV2_A2, PIN_SW_SOUTH_LV2_B2, IDX_CH_0);
|
||||
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A2].base,
|
||||
chrgios[IDX_GPO_SOU_SW_LV2_B2].base, IDX_CH_0);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -102,13 +104,14 @@ int chrg_switch_south_lv2_2 (eIDX_CH ch)
|
||||
}
|
||||
|
||||
// 南向通道选择
|
||||
int chrg_switch_south (eIDX_SOUTH_CH ch)
|
||||
int chrg_switch_south (eIDX_SOU_CH ch)
|
||||
{
|
||||
int ret = -1;
|
||||
if (ch >= TOTAL_SOU_CHS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 1级/2级通道顺序反向
|
||||
if ((IDX_SOU_CH1 == ch)||(IDX_SOU_CH2 == ch)) {
|
||||
ret = chrg_switch_south_lv1(IDX_CH_1);
|
||||
ret |= chrg_switch_south_lv2_2((eIDX_CH)ch);
|
||||
@@ -122,24 +125,8 @@ int chrg_switch_south (eIDX_SOUTH_CH ch)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int chrg_switch_south_pins_init (void)
|
||||
{
|
||||
rt_pin_mode(PIN_SW_SOUTH_LV1_A, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(PIN_SW_SOUTH_LV1_B, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(PIN_SW_SOUTH_LV2_A1, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(PIN_SW_SOUTH_LV2_B1, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(PIN_SW_SOUTH_LV2_A2, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(PIN_SW_SOUTH_LV2_B2, PIN_MODE_OUTPUT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int chrg_switch_init (void)
|
||||
{
|
||||
chrg_switch_north_pins_init();
|
||||
chrg_switch_south_pins_init();
|
||||
|
||||
chrg_switch_north(IDX_CH_0);
|
||||
chrg_switch_south(IDX_SOU_CH1);
|
||||
|
||||
@@ -150,6 +137,8 @@ static int chrg_switch_init (void)
|
||||
INIT_ENV_EXPORT(chrg_switch_init);
|
||||
|
||||
|
||||
#if 1
|
||||
|
||||
static int north_ch(rt_uint8_t argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -159,7 +148,7 @@ static int north_ch(rt_uint8_t argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = chrg_switch_north((eIDX_CH)atoi(argv[1]));
|
||||
ret = chrg_switch_north((eIDX_NOR_CH)atoi(argv[1]));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -177,7 +166,7 @@ static int south_ch(rt_uint8_t argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = chrg_switch_south((eIDX_SOUTH_CH)atoi(argv[1]));
|
||||
ret = chrg_switch_south((eIDX_SOU_CH)atoi(argv[1]));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -185,5 +174,6 @@ static int south_ch(rt_uint8_t argc, char **argv)
|
||||
|
||||
MSH_CMD_EXPORT(south_ch, south channel select);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include "drv_gpio.h"
|
||||
|
||||
#include "chrg_gpio.h"
|
||||
|
||||
#include "chrg_def.h"
|
||||
#include "chrg_source.h"
|
||||
@@ -19,7 +20,7 @@ typedef enum {
|
||||
IDX_CH_3, // J10 - -J15 -J19
|
||||
|
||||
TOTAL_CHS
|
||||
} eIDX_CH;
|
||||
} eIDX_CH, eIDX_NOR_CH;
|
||||
|
||||
// 南向选择 组合
|
||||
typedef enum {
|
||||
@@ -29,31 +30,14 @@ typedef enum {
|
||||
IDX_SOU_CH4, // U24_J12
|
||||
|
||||
TOTAL_SOU_CHS
|
||||
} eIDX_SOUTH_CH;
|
||||
|
||||
|
||||
// U14 switch
|
||||
#define PIN_SW_NORTH_A GET_PIN(B, 0)
|
||||
#define PIN_SW_NORTH_B GET_PIN(B, 1)
|
||||
|
||||
// U23 switch
|
||||
#define PIN_SW_SOUTH_LV1_A GET_PIN(C, 8)
|
||||
#define PIN_SW_SOUTH_LV1_B GET_PIN(C, 9)
|
||||
|
||||
// U24 switch
|
||||
#define PIN_SW_SOUTH_LV2_A1 GET_PIN(A, 15)
|
||||
#define PIN_SW_SOUTH_LV2_B1 GET_PIN(C, 10)
|
||||
|
||||
// U25 switch
|
||||
#define PIN_SW_SOUTH_LV2_A2 GET_PIN(C, 11)
|
||||
#define PIN_SW_SOUTH_LV2_B2 GET_PIN(C, 12)
|
||||
} eIDX_SOU_CH;
|
||||
|
||||
|
||||
// 北向通道选择
|
||||
extern int chrg_switch_north (eIDX_CH ch);
|
||||
extern int chrg_switch_north (eIDX_NOR_CH ch);
|
||||
|
||||
// 南向通道选择
|
||||
extern int chrg_switch_south (eIDX_SOUTH_CH ch);
|
||||
extern int chrg_switch_south (eIDX_SOU_CH ch);
|
||||
|
||||
struct chrg_switch_t {
|
||||
eIDX_ID id;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define DBG_TAG "chrg.vcom"
|
||||
#include <rtdbg.h>
|
||||
|
||||
#if 0
|
||||
int chrg_vcom_init (void)
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
@@ -28,16 +29,12 @@ int chrg_vcom_init (void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//INIT_COMPONENT_EXPORT(chrg_vcom_init);
|
||||
|
||||
#endif
|
||||
|
||||
int chrg_vcom_console_init (void)
|
||||
{
|
||||
rt_console_set_device(DEV_NAME_VCOM);
|
||||
|
||||
chrg_lcd_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define __CHRG_VCOM_H__
|
||||
|
||||
|
||||
#define DEV_NAME_VCOM "vcom"
|
||||
#define DEV_NAME_VCOM "vcom" // 控制台调试口
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@ rt_uint16_t usSRegHoldBuf[S_REG_HOLDING_NREGS];
|
||||
|
||||
|
||||
struct chrg_comm_t chrgcomm = {
|
||||
.name = THR_NAME_COMM,
|
||||
.devname = DEV_NAME_COMM,
|
||||
.tid = RT_NULL,
|
||||
.tty = RT_NULL,
|
||||
.rx_len = 0,
|
||||
.tx_len = 0,
|
||||
@@ -663,16 +661,23 @@ static int chrg_comm_parse_msg (struct chrg_comm_t *pCOMM)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void chrg_comm_thread_entry (void *data)
|
||||
void chrg_comm_thread_entry (void *data)
|
||||
{
|
||||
struct chrg_comm_t *pCOMM = (struct chrg_comm_t *)data;
|
||||
struct chrg_thread_t *pTHR = (struct chrg_thread_t *)data;
|
||||
|
||||
if ((RT_NULL == pCOMM)||(RT_NULL == pCOMM->tty)) {
|
||||
if (RT_NULL == pTHR) {
|
||||
return ;
|
||||
}
|
||||
|
||||
int len = 0;
|
||||
struct chrg_tty_t *pTTY = pCOMM->tty;
|
||||
struct chrg_tty_t *pTTY = RT_NULL;
|
||||
struct chrg_comm_t *pCOMM = &chrgcomm;
|
||||
|
||||
pTTY = chrg_tty_create(pCOMM->devname, BAUD_RATE_115200, 0, 8, 1);
|
||||
if (RT_NULL == pTTY) {
|
||||
LOG_E("tty can't create.");
|
||||
return ;
|
||||
}
|
||||
|
||||
chrg_tty_set_recv_tmo(pTTY, 8);
|
||||
if (chrg_tty_connect(pTTY) != RT_EOK) {
|
||||
@@ -681,8 +686,10 @@ static void chrg_comm_thread_entry (void *data)
|
||||
}
|
||||
chrg_tty_mode_set(pTTY, 0);
|
||||
|
||||
pCOMM->tty = pTTY;
|
||||
|
||||
while (1) {
|
||||
memset(pCOMM->rx_buf, 0, sizeof(pCOMM->rx_buf));
|
||||
rt_memset(pCOMM->rx_buf, 0, sizeof(pCOMM->rx_buf));
|
||||
len = chrg_tty_recv(pTTY, pCOMM->rx_buf, sizeof(pCOMM->rx_buf));
|
||||
if (len <= 0) {
|
||||
rt_thread_mdelay(1);
|
||||
@@ -696,39 +703,7 @@ static void chrg_comm_thread_entry (void *data)
|
||||
|
||||
}
|
||||
|
||||
static int chrg_comm_init (void)
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
struct chrg_comm_t *pCOMM = &chrgcomm;
|
||||
|
||||
pCOMM->tty = chrg_tty_create(pCOMM->devname, 115200, 0, 8, 1);
|
||||
if (RT_NULL == pCOMM->tty) {
|
||||
LOG_E("tty can't create.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rt_memset(pCOMM->rx_buf, 0, SIZE_BUF_TTY);
|
||||
|
||||
ret = rt_mutex_init(&pCOMM->lock, pCOMM->name, RT_IPC_FLAG_FIFO);
|
||||
if (ret != RT_EOK) {
|
||||
LOG_E("init mutex '%s' failed.", pCOMM->name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pCOMM->tid = rt_thread_create(pCOMM->name, chrg_comm_thread_entry, pCOMM, 4096,
|
||||
RT_MAIN_THREAD_PRIORITY, 20);
|
||||
if (RT_NULL != pCOMM->tid) {
|
||||
rt_thread_startup(pCOMM->tid);
|
||||
} else {
|
||||
LOG_E("create thread '%s' failed.", pCOMM->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
INIT_APP_EXPORT(chrg_comm_init);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -137,10 +137,7 @@ struct code_func_t {
|
||||
#define DEV_NAME_COMM "uart1"
|
||||
|
||||
struct chrg_comm_t {
|
||||
const char *name;
|
||||
const char *devname;
|
||||
struct rt_thread *tid;
|
||||
struct rt_mutex lock;
|
||||
|
||||
struct chrg_tty_t *tty;
|
||||
|
||||
@@ -154,7 +151,7 @@ struct chrg_comm_t {
|
||||
|
||||
extern struct chrg_comm_t chrgcomm;
|
||||
|
||||
|
||||
extern void chrg_comm_thread_entry (void *data);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_roll.h"
|
||||
|
||||
#include "chrg_north.h"
|
||||
#include "chrg_south.h"
|
||||
|
||||
@@ -25,9 +25,9 @@ static int chrg_lcd_parse (char *recv)
|
||||
|
||||
if (strstr(recv, "main.CH1_RunStop.txt")) {
|
||||
if (strstr(recv, "run")) {
|
||||
chrgroll.en_nor[IDX_CH_0] = 1;
|
||||
chrgnorth.enable[IDX_CH_0] = 1;
|
||||
} else if (strstr(recv, "stop")) {
|
||||
chrgroll.en_nor[IDX_CH_0] = 0;
|
||||
chrgnorth.enable[IDX_CH_0] = 0;
|
||||
}
|
||||
|
||||
// ...
|
||||
@@ -68,7 +68,7 @@ int chrg_lcd_send (char *cmd)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void chrg_lcd_thread_entry (void *data)
|
||||
void chrg_lcd_thread_entry (void *data)
|
||||
{
|
||||
struct chrg_lcd_t *pLCD = (struct chrg_lcd_t *)data;
|
||||
|
||||
@@ -130,8 +130,6 @@ int chrg_lcd_init (void)
|
||||
}
|
||||
|
||||
|
||||
//INIT_APP_EXPORT(chrg_lcd_init);
|
||||
|
||||
#if 1
|
||||
static int lcdsend(rt_uint8_t argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,9 @@ extern int chrg_lcd_send (char *cmd);
|
||||
|
||||
extern int chrg_lcd_init (void);
|
||||
|
||||
extern void chrg_lcd_thread_entry (void *data);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include <string.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_thread.h"
|
||||
#include "chrg_pkg.h"
|
||||
#include "chrg_north.h"
|
||||
#include "chrg_roll.h"
|
||||
#include "chrg_roll_nor.h"
|
||||
#include "chrg_utils.h"
|
||||
|
||||
#define LOG_TAG "chrg.nor"
|
||||
@@ -10,11 +12,10 @@
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_north_t chrgnorth = {
|
||||
.name = THR_NAME_NORTH,
|
||||
.devname = DEV_NAME_NORTH,
|
||||
.tid = RT_NULL,
|
||||
.tty = RT_NULL,
|
||||
.rx_len = 0,
|
||||
.enable = {1, 1, 1, 1},
|
||||
.sw[IDX_CH_0] = {
|
||||
.id = ID_SINK,
|
||||
},
|
||||
@@ -29,27 +30,6 @@ struct chrg_north_t chrgnorth = {
|
||||
},
|
||||
};
|
||||
|
||||
const rt_base_t sw_uart[TOTAL_CHS] = {
|
||||
PIN_NORTH_UART_SW1,
|
||||
PIN_NORTH_UART_SW2,
|
||||
PIN_NORTH_UART_SW3,
|
||||
PIN_NORTH_UART_SW4
|
||||
};
|
||||
|
||||
void chrg_north_sw_uart (eIDX_CH ch, eIDX_ID id)
|
||||
{
|
||||
if (ch >= TOTAL_CHS) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (ID_SOURCE == id) {
|
||||
rt_pin_write(sw_uart[ch], PIN_HIGH);
|
||||
} else if (ID_SINK == id) {
|
||||
rt_pin_write(sw_uart[ch], PIN_LOW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int chrg_north_send (rt_uint8_t *data, rt_size_t length)
|
||||
{
|
||||
rt_ssize_t ret = -1;
|
||||
@@ -62,86 +42,213 @@ int chrg_north_send (rt_uint8_t *data, rt_size_t length)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void chrg_north_thread_entry (void *data)
|
||||
// 提取3字节帧头
|
||||
static int chrg_north_frame_head (struct rt_ringbuffer *rb, rt_uint8_t *head, eIDX_ID id)
|
||||
{
|
||||
struct chrg_north_t *pNOR = (struct chrg_north_t *)data;
|
||||
int i = 0;
|
||||
rt_uint8_t data = 0, stage = 0;
|
||||
rt_size_t ret = 0;
|
||||
rt_size_t len_rb = 0; // ring数据长度
|
||||
rt_uint8_t len_frame = 0; // 帧长度
|
||||
|
||||
if ((RT_NULL == pNOR)||(RT_NULL == pNOR->tty)) {
|
||||
if (RT_NULL == rb) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
len_rb = rt_ringbuffer_data_len(rb);
|
||||
if (len_rb < LEN_FRAME_HEAD + 2) { // 最短5字节
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < len_rb - 2; i++) { // 找头三个字节 [帧长, 0x00, id]
|
||||
ret = rt_ringbuffer_getchar(rb, &data);
|
||||
if (0 == ret) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (stage) {
|
||||
case 0:
|
||||
head[0] = data;
|
||||
len_frame = data;
|
||||
if (data < MIN_FRAME_LENGTH) { // 长度不符
|
||||
stage = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
stage = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
head[1] = data;
|
||||
if (0x00 != data) {
|
||||
stage = 0;
|
||||
} else {
|
||||
stage = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
head[2] = data;
|
||||
if ((rt_uint8_t)id != data) {
|
||||
stage = 0;
|
||||
} else {
|
||||
return len_frame;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int chrg_north_pickup_frame (struct rt_ringbuffer *rb,
|
||||
struct pickup_info_t *pFrame, eIDX_NOR_CH idx)
|
||||
{
|
||||
int cnt = 0;
|
||||
rt_size_t len_rb = 0;
|
||||
|
||||
if ((RT_NULL == rb)||(RT_NULL == pFrame)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct chrg_switch_t *pSW = &chrgnorth.sw[idx];
|
||||
|
||||
do {
|
||||
if (0 == pFrame->findhead) {
|
||||
pFrame->len_msg = chrg_north_frame_head(rb, pFrame->head, pSW->id);
|
||||
if (pFrame->len_msg > 0) {
|
||||
pFrame->pMB = (struct mb_msg_t *)rt_malloc(sizeof(struct mb_msg_t));
|
||||
if (RT_NULL == pFrame->pMB) {
|
||||
LOG_E("malloc mb failed.");
|
||||
return -2;
|
||||
}
|
||||
|
||||
pFrame->pMB->length = pFrame->len_msg;
|
||||
if (pFrame->pMB->length >= SIZE_BUF_TTY) {
|
||||
rt_free(pFrame->pMB);
|
||||
pFrame->pMB = RT_NULL;
|
||||
LOG_E("too long msg.");
|
||||
return -3;
|
||||
}
|
||||
|
||||
pFrame->pMB->payload = (rt_uint8_t *)rt_malloc(pFrame->len_msg);
|
||||
if (RT_NULL == pFrame->pMB->payload) {
|
||||
LOG_E("malloc buf failed.");
|
||||
return -4;
|
||||
}
|
||||
|
||||
memcpy(pFrame->pMB->payload, pFrame->head, LEN_FRAME_HEAD);
|
||||
|
||||
len_rb = rt_ringbuffer_data_len(rb);
|
||||
if (len_rb >= pFrame->len_msg - LEN_FRAME_HEAD) {
|
||||
rt_ringbuffer_get(rb, &pFrame->pMB->payload[LEN_FRAME_HEAD], pFrame->len_msg - LEN_FRAME_HEAD);
|
||||
|
||||
chrg_thread_mb_send(IDX_THR_NORTH, pFrame->pMB);
|
||||
//chrg_pkg_decode(pFrame->pMB->payload, pFrame->len_msg, pSW);
|
||||
|
||||
pFrame->length = 0;
|
||||
pFrame->len_msg = 0;
|
||||
cnt++;
|
||||
} else {
|
||||
rt_ringbuffer_get(rb, &pFrame->pMB->payload[LEN_FRAME_HEAD], len_rb);
|
||||
pFrame->length = LEN_FRAME_HEAD + len_rb;
|
||||
pFrame->findhead = 1;
|
||||
pFrame->last_tick = rt_tick_get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
len_rb = rt_ringbuffer_data_len(rb);
|
||||
int len_need = pFrame->len_msg - LEN_FRAME_HEAD;
|
||||
if (len_rb >= len_need) {
|
||||
rt_ringbuffer_get(rb, &pFrame->pMB->payload[pFrame->length], len_need);
|
||||
|
||||
chrg_thread_mb_send(IDX_THR_NORTH, pFrame->pMB);
|
||||
//chrg_pkg_decode(pFrame->pMB->payload, pFrame->len_msg, pSW);
|
||||
|
||||
pFrame->length = 0;
|
||||
pFrame->findhead = 0;
|
||||
pFrame->len_msg = 0;
|
||||
cnt++;
|
||||
} else {
|
||||
rt_ringbuffer_get(rb, &pFrame->pMB->payload[pFrame->length], len_rb);
|
||||
pFrame->length += len_rb;
|
||||
pFrame->last_tick = rt_tick_get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
len_rb = rt_ringbuffer_data_len(rb);
|
||||
} while (len_rb >= LEN_FRAME_HEAD);
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
void chrg_north_thread_entry (void *data)
|
||||
{
|
||||
struct chrg_thread_t *pTHR = (struct chrg_thread_t *)data;
|
||||
|
||||
if (RT_NULL == pTHR) {
|
||||
return ;
|
||||
}
|
||||
|
||||
int len = 0;
|
||||
struct chrg_tty_t *pTTY = pNOR->tty;
|
||||
struct chrg_tty_t *pTTY = RT_NULL;
|
||||
struct chrg_north_t *pNOR = &chrgnorth;
|
||||
|
||||
pTTY = chrg_tty_create(pNOR->devname, BAUD_RATE_2000000, 0, -1, 1);
|
||||
if (RT_NULL == pTTY) {
|
||||
LOG_E("tty can't create.");
|
||||
return ;
|
||||
}
|
||||
|
||||
chrg_tty_set_recv_tmo(pTTY, 100);
|
||||
if (chrg_tty_connect(pTTY) != RT_EOK) {
|
||||
chrg_tty_destory(pTTY);
|
||||
return;
|
||||
return ;
|
||||
}
|
||||
|
||||
pNOR->tty = pTTY;
|
||||
|
||||
pNOR->rb = rt_ringbuffer_create(SIZE_BUF_TTY*2);
|
||||
if (RT_NULL == pNOR->rb) {
|
||||
LOG_E("create rb '%s' failed.", pNOR->devname);
|
||||
return ;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
memset(pNOR->rx_buf, 0, sizeof(pNOR->rx_buf));
|
||||
rt_memset(pNOR->rx_buf, 0, sizeof(pNOR->rx_buf));
|
||||
len = chrg_tty_recv(pTTY, pNOR->rx_buf, sizeof(pNOR->rx_buf));
|
||||
if (len <= 0) {
|
||||
rt_thread_mdelay(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
rt_ringbuffer_put(pNOR->rb, pNOR->rx_buf, len);
|
||||
|
||||
//rt_kprintf("%s\r\n", (char *)pNOR->rx_buf);
|
||||
//chrg_tty_send(pTTY, pNOR->rx_buf, len);
|
||||
|
||||
chrg_roll_evt_send();
|
||||
|
||||
if (1 == pNOR->frame.findhead) {
|
||||
if (rt_tick_get() >= pNOR->frame.last_tick + 100) { // 100ms
|
||||
pNOR->frame.findhead = 0; // reset
|
||||
//LOG_E("timeo\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
chrg_north_pickup_frame(pNOR->rb, &pNOR->frame, pNOR->idx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int chrg_north_init (void)
|
||||
{
|
||||
rt_err_t ret;
|
||||
struct chrg_north_t *pNOR = &chrgnorth;
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < TOTAL_CHS; i++) {
|
||||
rt_pin_mode(sw_uart[i], PIN_MODE_OUTPUT);
|
||||
chrg_north_sw_uart((eIDX_CH)i, ID_SINK);
|
||||
}
|
||||
|
||||
pNOR->tty = chrg_tty_create(pNOR->devname, 2000000, 0, -1, 1);
|
||||
if (RT_NULL == pNOR->tty) {
|
||||
LOG_E("tty can't create.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rt_memset(pNOR->rx_buf, 0, SIZE_BUF_TTY);
|
||||
|
||||
ret = rt_mutex_init(&pNOR->lock, pNOR->name, RT_IPC_FLAG_FIFO);
|
||||
if (ret != RT_EOK) {
|
||||
LOG_E("init mutex '%s' failed.", pNOR->name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pNOR->tid = rt_thread_create(pNOR->name, chrg_north_thread_entry, pNOR, 4096,
|
||||
RT_MAIN_THREAD_PRIORITY, 20);
|
||||
if (RT_NULL != pNOR->tid) {
|
||||
rt_thread_startup(pNOR->tid);
|
||||
} else {
|
||||
LOG_E("create thread '%s' failed.", pNOR->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INIT_APP_EXPORT(chrg_north_init);
|
||||
|
||||
|
||||
#if 0
|
||||
static int north_send(rt_uint8_t argc, char **argv)
|
||||
{
|
||||
return chrg_north_send("1234567890abcdef", 16);
|
||||
return source_get_vc(5000, 1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,33 +10,39 @@
|
||||
#define THR_NAME_NORTH "thr.nor"
|
||||
#define DEV_NAME_NORTH "uart3"
|
||||
|
||||
#define LEN_FRAME_HEAD (3) // [帧长, 0x00, id]
|
||||
#define MIN_FRAME_LENGTH (5) // 帧最短5字节
|
||||
|
||||
#define PIN_NORTH_UART_SW1 GET_PIN(C, 0)
|
||||
#define PIN_NORTH_UART_SW2 GET_PIN(A, 0)
|
||||
#define PIN_NORTH_UART_SW3 GET_PIN(A, 6)
|
||||
#define PIN_NORTH_UART_SW4 GET_PIN(B, 12)
|
||||
|
||||
struct pickup_info_t {
|
||||
rt_tick_t last_tick; // 前次收数据时刻
|
||||
rt_uint16_t length; // 已提取数据字节数
|
||||
rt_uint8_t findhead; // 找到帧头
|
||||
rt_uint8_t head[8]; // 帧头填充区
|
||||
int len_msg; // 数据长度
|
||||
struct mb_msg_t *pMB; // 邮件
|
||||
};
|
||||
|
||||
struct chrg_north_t {
|
||||
const char *name;
|
||||
const char *devname;
|
||||
struct rt_thread *tid;
|
||||
struct rt_mutex lock;
|
||||
const char *devname;
|
||||
|
||||
struct chrg_tty_t *tty;
|
||||
rt_uint16_t rx_len;
|
||||
rt_uint8_t rx_buf[SIZE_BUF_TTY];
|
||||
struct chrg_tty_t *tty;
|
||||
struct rt_ringbuffer *rb;
|
||||
struct pickup_info_t frame;
|
||||
|
||||
eIDX_CH idx; // 当前通路
|
||||
struct chrg_switch_t sw[TOTAL_CHS];
|
||||
rt_uint16_t rx_len;
|
||||
rt_uint8_t rx_buf[SIZE_BUF_TTY];
|
||||
|
||||
rt_uint8_t enable[TOTAL_CHS]; // 通路使能
|
||||
eIDX_NOR_CH idx; // 当前通路
|
||||
struct chrg_switch_t sw[TOTAL_CHS];
|
||||
};
|
||||
|
||||
extern struct chrg_north_t chrgnorth;
|
||||
|
||||
extern void chrg_north_sw_uart (eIDX_CH ch, eIDX_ID id);
|
||||
|
||||
extern int chrg_north_send (rt_uint8_t *data, rt_size_t length);
|
||||
|
||||
extern void chrg_north_thread_entry (void *data);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_north.h"
|
||||
#include "chrg_south.h"
|
||||
#include "chrg_sink.h"
|
||||
#include "chrg_source.h"
|
||||
#include "chrg_roll.h"
|
||||
|
||||
#define LOG_TAG "chrg.roll"
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_roll_t chrgroll = {
|
||||
.name = THR_NAME_ROLL,
|
||||
.tid = RT_NULL,
|
||||
.idx = 0,
|
||||
.en_nor = {1, 1, 1, 1},
|
||||
.en_sou = {1, 1, 1, 1},
|
||||
};
|
||||
|
||||
rt_uint8_t chrg_roll_get_idx (void)
|
||||
{
|
||||
rt_uint8_t idx = 0;
|
||||
struct chrg_roll_t *pROLL = &chrgroll;
|
||||
|
||||
rt_mutex_take(pROLL->mutex, RT_WAITING_FOREVER);
|
||||
idx = pROLL->idx;
|
||||
rt_mutex_release(pROLL->mutex);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
void chrg_roll_evt_send (void)
|
||||
{
|
||||
struct chrg_roll_t *pROLL = &chrgroll;
|
||||
if (RT_NULL != pROLL->evt) {
|
||||
rt_event_send(pROLL->evt, ROLL_EVT_RECVED);
|
||||
}
|
||||
}
|
||||
|
||||
static void chrg_roll_thread_entry (void *data)
|
||||
{
|
||||
struct chrg_roll_t *pROLL = (struct chrg_roll_t *)data;
|
||||
|
||||
if (RT_NULL == pROLL) {
|
||||
return ;
|
||||
}
|
||||
|
||||
rt_uint8_t idx = 0, sou_idx = 0;
|
||||
rt_err_t ret = RT_EOK;
|
||||
rt_uint32_t recved = 0;
|
||||
struct chrg_north_t *pNOR = &chrgnorth;
|
||||
struct chrg_south_t *pSOU = &chrgsouth;
|
||||
struct chrg_switch_t *pSW = RT_NULL;
|
||||
|
||||
while (1) {
|
||||
rt_mutex_take(pROLL->mutex, RT_WAITING_FOREVER);
|
||||
pROLL->idx = idx%(TOTAL_CHS+TOTAL_SOU_CHS);
|
||||
rt_mutex_release(pROLL->mutex);
|
||||
|
||||
if (pROLL->idx < TOTAL_CHS) {
|
||||
if (0 == pROLL->en_nor[pROLL->idx]) {
|
||||
idx++;
|
||||
rt_thread_mdelay(1);
|
||||
continue;
|
||||
} else {
|
||||
pNOR->idx = (eIDX_CH)pROLL->idx;
|
||||
chrg_switch_north(pNOR->idx);
|
||||
|
||||
pSW = &pNOR->sw[pNOR->idx];
|
||||
if (ID_SOURCE == pSW->id) {
|
||||
chrg_north_sw_uart(pNOR->idx, ID_SOURCE);
|
||||
source_get_vc(pSW->source.voltage, pSW->source.current);
|
||||
} else if (ID_SINK == pSW->id) {
|
||||
chrg_north_sw_uart(pNOR->idx, ID_SINK);
|
||||
sink_get_vc(pSW->sink.loadv, pSW->sink.loadc);
|
||||
}
|
||||
|
||||
//rt_kprintf("Nor[%d].%d\r\n", pNOR->idx, pSW->id);
|
||||
}
|
||||
} else {
|
||||
sou_idx = pROLL->idx - TOTAL_CHS;
|
||||
if (0 == pROLL->en_sou[sou_idx]) {
|
||||
idx++;
|
||||
rt_thread_mdelay(1);
|
||||
continue;
|
||||
} else {
|
||||
pSOU->idx = (eIDX_SOUTH_CH)sou_idx;
|
||||
chrg_switch_south(pSOU->idx);
|
||||
|
||||
pSW = &pSOU->sw[pSOU->idx];
|
||||
if (ID_ELOAD == pSW->id) {
|
||||
source_get_vc(pSW->source.voltage, pSW->source.current);
|
||||
// change pro modbus
|
||||
}
|
||||
//rt_kprintf("Sou[%d].%d\r\n", pSOU->idx, pSW->id);
|
||||
}
|
||||
}
|
||||
|
||||
idx++;
|
||||
|
||||
ret = rt_event_recv(pROLL->evt, ROLL_EVT_RECVED,
|
||||
(RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR), 100, &recved); // wait 100ms
|
||||
if (RT_EOK != ret) {
|
||||
//LOG_E("evt recv failed. [%d]", ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (recved & ROLL_EVT_RECVED) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int chrg_roll_init (void)
|
||||
{
|
||||
struct chrg_roll_t *pROLL = &chrgroll;
|
||||
|
||||
pROLL->mutex = rt_mutex_create(pROLL->name, RT_IPC_FLAG_FIFO);
|
||||
if (RT_NULL == pROLL->mutex) {
|
||||
LOG_E("create mutex '%s' failed.", pROLL->name);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
pROLL->evt = rt_event_create(pROLL->name, RT_IPC_FLAG_FIFO);
|
||||
if (RT_NULL == pROLL->evt) {
|
||||
LOG_E("create ev '%s' failed.", pROLL->name);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
pROLL->tid = rt_thread_create(pROLL->name, chrg_roll_thread_entry, pROLL, 2048,
|
||||
RT_MAIN_THREAD_PRIORITY, 20);
|
||||
if (RT_NULL != pROLL->tid) {
|
||||
rt_thread_startup(pROLL->tid);
|
||||
} else {
|
||||
LOG_E("create thread '%s' failed.", pROLL->name);
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
||||
INIT_APP_EXPORT(chrg_roll_init);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef __CHRG_ROLL_H__
|
||||
#define __CHRG_ROLL_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_switch.h"
|
||||
|
||||
#define THR_NAME_ROLL "thr.roll"
|
||||
|
||||
#define ROLL_EVT_RECVED (1<<0) // 收到数据
|
||||
|
||||
|
||||
struct chrg_roll_t {
|
||||
const char *name;
|
||||
struct rt_thread *tid;
|
||||
|
||||
rt_mutex_t mutex;
|
||||
rt_event_t evt;
|
||||
|
||||
rt_uint8_t idx; // 轮巡索引 0-3:nor 4-11:sou
|
||||
|
||||
rt_uint8_t en_nor[TOTAL_CHS]; // 北向通路使能
|
||||
rt_uint8_t en_sou[TOTAL_SOU_CHS]; // 南向通路使能
|
||||
};
|
||||
|
||||
extern struct chrg_roll_t chrgroll;
|
||||
|
||||
extern rt_uint8_t chrg_roll_get_idx (void);
|
||||
|
||||
extern void chrg_roll_evt_send (void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_gpio.h"
|
||||
#include "chrg_thread.h"
|
||||
#include "chrg_sink.h"
|
||||
#include "chrg_source.h"
|
||||
#include "chrg_roll_nor.h"
|
||||
#include "chrg_switch.h"
|
||||
|
||||
#define LOG_TAG "chrg.rollnor"
|
||||
#include <rtdbg.h>
|
||||
|
||||
const rt_base_t sw_uart[TOTAL_CHS] = {
|
||||
IDX_GPO_UART_SW1,
|
||||
IDX_GPO_UART_SW2,
|
||||
IDX_GPO_UART_SW3,
|
||||
IDX_GPO_UART_SW4
|
||||
};
|
||||
|
||||
static void chrg_roll_nor_sw_uart (eIDX_CH ch, eIDX_ID id)
|
||||
{
|
||||
if (ch >= TOTAL_CHS) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (ID_SOURCE == id) {
|
||||
rt_pin_write(chrgios[sw_uart[ch]].base, PIN_HIGH);
|
||||
} else if (ID_SINK == id) {
|
||||
rt_pin_write(chrgios[sw_uart[ch]].base, PIN_LOW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void chrg_roll_nor_thread_entry (void *data)
|
||||
{
|
||||
struct chrg_thread_t *pTHR = (struct chrg_thread_t *)data;
|
||||
|
||||
if (RT_NULL == pTHR) {
|
||||
return ;
|
||||
}
|
||||
|
||||
rt_uint8_t idx = 0, i = 0;
|
||||
rt_err_t ret = RT_EOK;
|
||||
struct chrg_thread_t *pTN = &chrgthr[IDX_THR_NORTH];
|
||||
struct chrg_north_t *pNOR = &chrgnorth;
|
||||
struct chrg_switch_t *pSW = RT_NULL;
|
||||
struct mb_msg_t *pMB_R = RT_NULL;
|
||||
|
||||
for (i = 0; i < TOTAL_CHS; i++) {
|
||||
chrg_roll_nor_sw_uart((eIDX_CH)i, ID_SINK);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
|
||||
pNOR->idx = idx%(TOTAL_CHS+TOTAL_SOU_CHS);
|
||||
rt_mutex_release(pTHR->mutex);
|
||||
|
||||
if (pNOR->idx < TOTAL_CHS) {
|
||||
if (0 == pNOR->enable[pNOR->idx]) {
|
||||
idx++;
|
||||
rt_thread_mdelay(1);
|
||||
continue;
|
||||
} else {
|
||||
pNOR->idx = (eIDX_CH)pNOR->idx;
|
||||
chrg_switch_north(pNOR->idx);
|
||||
|
||||
pSW = &pNOR->sw[pNOR->idx];
|
||||
if (ID_SOURCE == pSW->id) {
|
||||
chrg_roll_nor_sw_uart(pNOR->idx, ID_SOURCE);
|
||||
source_get_vc(pSW->source.voltage, pSW->source.current);
|
||||
} else if (ID_SINK == pSW->id) {
|
||||
chrg_roll_nor_sw_uart(pNOR->idx, ID_SINK);
|
||||
sink_get_vc(pSW->sink.loadv, pSW->sink.loadc);
|
||||
}
|
||||
|
||||
//rt_kprintf("Nor[%d].%d\r\n", pNOR->idx, pSW->id);
|
||||
}
|
||||
}
|
||||
|
||||
idx++;
|
||||
|
||||
ret = rt_mb_recv(pTN->mb, (rt_uint32_t *)&pMB_R, 100); // 超时 100ms
|
||||
if ((RT_EOK == ret)&&(RT_NULL != pMB_R)) {
|
||||
// todo mail data
|
||||
|
||||
|
||||
if (RT_NULL != pMB_R->payload) {
|
||||
rt_free(pMB_R->payload);
|
||||
pMB_R->payload = RT_NULL;
|
||||
}
|
||||
|
||||
if (RT_NULL != pMB_R) {
|
||||
rt_free(pMB_R);
|
||||
pMB_R = RT_NULL;
|
||||
}
|
||||
|
||||
rt_thread_mdelay(50); // 间隔 50ms
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef __CHRG_ROLL_NOR_H__
|
||||
#define __CHRG_ROLL_NOR_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#define THR_NAME_ROLL_NOR "thr.rollnor"
|
||||
|
||||
|
||||
#define ROLL_NOR_EVT_RECVED (1<<0) // 收到北向数据
|
||||
|
||||
|
||||
extern void chrg_roll_nor_thread_entry (void *data);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
|
||||
#include "chrg_thread.h"
|
||||
#include "chrg_roll_sou.h"
|
||||
#include "chrg_switch.h"
|
||||
|
||||
#define LOG_TAG "chrg.rollsou"
|
||||
#include <rtdbg.h>
|
||||
|
||||
|
||||
void chrg_roll_sou_evt_send (void)
|
||||
{
|
||||
struct chrg_thread_t *pTHR = &chrgthr[IDX_THR_ROLL_SOU];
|
||||
if (RT_NULL != pTHR->ev) {
|
||||
rt_event_send(pTHR->ev, ROLL_SOU_EVT_RECVED);
|
||||
}
|
||||
}
|
||||
|
||||
void chrg_roll_sou_thread_entry (void *data)
|
||||
{
|
||||
struct chrg_thread_t *pTHR = (struct chrg_thread_t *)data;
|
||||
|
||||
if (RT_NULL == pTHR) {
|
||||
return ;
|
||||
}
|
||||
|
||||
rt_uint8_t idx = 0;
|
||||
rt_err_t ret = RT_EOK;
|
||||
struct chrg_south_t *pSOU = &chrgsouth;
|
||||
struct chrg_thread_t *pTS = &chrgthr[IDX_THR_SOUTH];
|
||||
struct mb_msg_t *pMB_R = RT_NULL;
|
||||
|
||||
while (1) {
|
||||
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
|
||||
pSOU->idx = idx%(TOTAL_CHS+TOTAL_SOU_CHS);
|
||||
rt_mutex_release(pTHR->mutex);
|
||||
|
||||
if (pSOU->idx < TOTAL_SOU_CHS) {
|
||||
if (0 == pSOU->enable[pSOU->idx]) {
|
||||
idx++;
|
||||
rt_thread_mdelay(10);
|
||||
continue;
|
||||
} else {
|
||||
pSOU->idx = (eIDX_SOU_CH)pSOU->idx;
|
||||
chrg_switch_south(pSOU->idx);
|
||||
|
||||
|
||||
|
||||
//rt_kprintf("Sou[%d].%d\r\n", pSOU->idx, pSOU->id);
|
||||
}
|
||||
}
|
||||
|
||||
idx++;
|
||||
|
||||
ret = rt_mb_recv(pTS->mb, (rt_uint32_t *)&pMB_R, 100); // 超时 100ms
|
||||
if ((RT_EOK == ret)&&(RT_NULL != pMB_R)) {
|
||||
// todo mail data
|
||||
|
||||
|
||||
if (RT_NULL != pMB_R->payload) {
|
||||
rt_free(pMB_R->payload);
|
||||
pMB_R->payload = RT_NULL;
|
||||
}
|
||||
|
||||
if (RT_NULL != pMB_R) {
|
||||
rt_free(pMB_R);
|
||||
pMB_R = RT_NULL;
|
||||
}
|
||||
|
||||
rt_thread_mdelay(50); // 间隔 50ms
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef __CHRG_ROLL_SOU_H__
|
||||
#define __CHRG_ROLL_SOU_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
|
||||
#define THR_NAME_ROLL_SOU "thr.rollsou"
|
||||
|
||||
#define ROLL_SOU_EVT_RECVED (1<<0) // 收到南向数据
|
||||
|
||||
|
||||
|
||||
extern void chrg_roll_sou_evt_send (void);
|
||||
|
||||
extern void chrg_roll_sou_thread_entry (void *data);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_thread.h"
|
||||
#include "chrg_south.h"
|
||||
#include "chrg_roll.h"
|
||||
#include "chrg_roll_sou.h"
|
||||
#include "chrg_utils.h"
|
||||
|
||||
#define LOG_TAG "chrg.sou"
|
||||
@@ -10,11 +11,11 @@
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_south_t chrgsouth = {
|
||||
.name = THR_NAME_SOUTH,
|
||||
.devname = DEV_NAME_SOUTH,
|
||||
.tid = RT_NULL,
|
||||
.tty = RT_NULL,
|
||||
.rx_len = 0,
|
||||
.enable = {1, 1, 1, 1},
|
||||
.idx = IDX_SOU_CH1,
|
||||
.sw[IDX_SOU_CH1] = {
|
||||
.id = ID_ELOAD,
|
||||
},
|
||||
@@ -42,16 +43,23 @@ int chrg_south_send (rt_uint8_t *data, rt_size_t length)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void chrg_south_thread_entry (void *data)
|
||||
void chrg_south_thread_entry (void *data)
|
||||
{
|
||||
struct chrg_south_t *pSOU = (struct chrg_south_t *)data;
|
||||
struct chrg_thread_t *pTHR = (struct chrg_thread_t *)data;
|
||||
|
||||
if ((RT_NULL == pSOU)||(RT_NULL == pSOU->tty)) {
|
||||
if (RT_NULL == pTHR) {
|
||||
return ;
|
||||
}
|
||||
|
||||
int len = 0;
|
||||
struct chrg_tty_t *pTTY = pSOU->tty;
|
||||
struct chrg_tty_t *pTTY = RT_NULL;
|
||||
struct chrg_south_t *pSOU = &chrgsouth;
|
||||
|
||||
pTTY = chrg_tty_create(pSOU->devname, BAUD_RATE_115200, 0, -1, 1);
|
||||
if (RT_NULL == pTTY) {
|
||||
LOG_E("tty can't create.");
|
||||
return ;
|
||||
}
|
||||
|
||||
chrg_tty_set_recv_tmo(pTTY, 100);
|
||||
if (chrg_tty_connect(pTTY) != RT_EOK) {
|
||||
@@ -59,7 +67,10 @@ static void chrg_south_thread_entry (void *data)
|
||||
return;
|
||||
}
|
||||
|
||||
pSOU->tty = pTTY;
|
||||
|
||||
while (1) {
|
||||
rt_memset(pSOU->rx_buf, 0, sizeof(pSOU->rx_buf));
|
||||
len = chrg_tty_recv(pTTY, pSOU->rx_buf, sizeof(pSOU->rx_buf));
|
||||
if (len <= 0) {
|
||||
rt_thread_mdelay(1);
|
||||
@@ -68,48 +79,13 @@ static void chrg_south_thread_entry (void *data)
|
||||
|
||||
// pick data & update sw
|
||||
|
||||
//rt_kprintf("%s\r\n", (char *)pSOU->rx_buf);
|
||||
//chrg_tty_send(pTTY, pSOU->rx_buf, len);
|
||||
|
||||
chrg_roll_evt_send();
|
||||
|
||||
//chrg_thread_mb_send(IDX_THR_NORTH, pFrame->pMB);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int chrg_south_init (void)
|
||||
{
|
||||
rt_err_t ret;
|
||||
struct chrg_south_t *pSOU = &chrgsouth;
|
||||
|
||||
pSOU->tty = chrg_tty_create(pSOU->devname, 115200, 0, -1, 1);
|
||||
if (RT_NULL == pSOU->tty) {
|
||||
LOG_E("tty can't create.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rt_memset(pSOU->rx_buf, 0, SIZE_BUF_TTY);
|
||||
|
||||
ret = rt_mutex_init(&pSOU->lock, pSOU->name, RT_IPC_FLAG_FIFO);
|
||||
if (ret != RT_EOK) {
|
||||
LOG_E("init mutex '%s' failed.", pSOU->name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pSOU->tid = rt_thread_create(pSOU->name, chrg_south_thread_entry, pSOU, 4096,
|
||||
RT_MAIN_THREAD_PRIORITY, 20);
|
||||
if (RT_NULL != pSOU->tid) {
|
||||
rt_thread_startup(pSOU->tid);
|
||||
} else {
|
||||
LOG_E("create thread '%s' failed.", pSOU->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INIT_APP_EXPORT(chrg_south_init);
|
||||
|
||||
#if 1
|
||||
static int south_send(rt_uint8_t argc, char **argv)
|
||||
@@ -123,3 +99,4 @@ MSH_CMD_EXPORT(south_send, south send test);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,16 +10,14 @@
|
||||
#define DEV_NAME_SOUTH "uart6"
|
||||
|
||||
struct chrg_south_t {
|
||||
const char *name;
|
||||
const char *devname;
|
||||
struct rt_thread *tid;
|
||||
struct rt_mutex lock;
|
||||
|
||||
struct chrg_tty_t *tty;
|
||||
rt_uint16_t rx_len;
|
||||
rt_uint8_t rx_buf[SIZE_BUF_TTY];
|
||||
|
||||
eIDX_SOUTH_CH idx; // 当前通路
|
||||
rt_uint8_t enable[TOTAL_SOU_CHS]; // 通路使能
|
||||
eIDX_SOU_CH idx; // 当前通路
|
||||
struct chrg_switch_t sw[TOTAL_SOU_CHS];
|
||||
};
|
||||
|
||||
@@ -27,6 +25,8 @@ extern struct chrg_south_t chrgsouth;
|
||||
|
||||
extern int chrg_south_send (rt_uint8_t *data, rt_size_t length);
|
||||
|
||||
extern void chrg_south_thread_entry (void *data);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_thread.h"
|
||||
|
||||
|
||||
#define LOG_TAG "chrg.thr"
|
||||
#define DBG_LVL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_thread_t chrgthr[TOTAL_THRS] = {
|
||||
[IDX_THR_NORTH] = {
|
||||
.name = THR_NAME_NORTH,
|
||||
.tid = RT_NULL,
|
||||
.mutex = RT_NULL,
|
||||
.sem = RT_NULL,
|
||||
.mb = RT_NULL,
|
||||
.ev = RT_NULL,
|
||||
.mq = RT_NULL,
|
||||
.mask = EN_THR_MUTEX | EN_THR_MAILBOX,
|
||||
.index = IDX_THR_NORTH,
|
||||
.priority = PRI_THR_NORTH,
|
||||
.stack = 2048,
|
||||
.tick = 20,
|
||||
.entry = chrg_north_thread_entry,
|
||||
},
|
||||
|
||||
[IDX_THR_SOUTH] = {
|
||||
.name = THR_NAME_SOUTH,
|
||||
.tid = RT_NULL,
|
||||
.mutex = RT_NULL,
|
||||
.sem = RT_NULL,
|
||||
.mb = RT_NULL,
|
||||
.ev = RT_NULL,
|
||||
.mq = RT_NULL,
|
||||
.mask = EN_THR_MUTEX | EN_THR_MAILBOX,
|
||||
.index = IDX_THR_SOUTH,
|
||||
.priority = PRI_THR_SOUTH,
|
||||
.stack = 2048,
|
||||
.tick = 20,
|
||||
.entry = chrg_south_thread_entry,
|
||||
},
|
||||
|
||||
[IDX_THR_COMM] = {
|
||||
.name = THR_NAME_COMM,
|
||||
.tid = RT_NULL,
|
||||
.mutex = RT_NULL,
|
||||
.sem = RT_NULL,
|
||||
.mb = RT_NULL,
|
||||
.ev = RT_NULL,
|
||||
.mq = RT_NULL,
|
||||
.mask = EN_THR_MUTEX | EN_THR_MAILBOX,
|
||||
.index = IDX_THR_COMM,
|
||||
.priority = PRI_THR_COMM,
|
||||
.stack = 2048,
|
||||
.tick = 20,
|
||||
.entry = chrg_comm_thread_entry,
|
||||
},
|
||||
|
||||
[IDX_THR_LCD] = {
|
||||
.name = THR_NAME_LCD,
|
||||
.tid = RT_NULL,
|
||||
.mutex = RT_NULL,
|
||||
.sem = RT_NULL,
|
||||
.mb = RT_NULL,
|
||||
.ev = RT_NULL,
|
||||
.mq = RT_NULL,
|
||||
.mask = EN_THR_MUTEX,
|
||||
.index = IDX_THR_LCD,
|
||||
.priority = PRI_THR_LCD,
|
||||
.stack = 2048,
|
||||
.tick = 20,
|
||||
.entry = chrg_lcd_thread_entry,
|
||||
},
|
||||
|
||||
[IDX_THR_ROLL_NOR] = {
|
||||
.name = THR_NAME_ROLL_NOR,
|
||||
.tid = RT_NULL,
|
||||
.mutex = RT_NULL,
|
||||
.sem = RT_NULL,
|
||||
.mb = RT_NULL,
|
||||
.ev = RT_NULL,
|
||||
.mq = RT_NULL,
|
||||
.mask = EN_THR_MUTEX | EN_THR_EVENT,
|
||||
.index = IDX_THR_ROLL_NOR,
|
||||
.priority = PRI_THR_ROLL_NOR,
|
||||
.stack = 2048,
|
||||
.tick = 20,
|
||||
.entry = chrg_roll_nor_thread_entry,
|
||||
},
|
||||
|
||||
[IDX_THR_ROLL_SOU] = {
|
||||
.name = THR_NAME_ROLL_SOU,
|
||||
.tid = RT_NULL,
|
||||
.mutex = RT_NULL,
|
||||
.sem = RT_NULL,
|
||||
.mb = RT_NULL,
|
||||
.ev = RT_NULL,
|
||||
.mq = RT_NULL,
|
||||
.mask = EN_THR_MUTEX | EN_THR_EVENT,
|
||||
.index = IDX_THR_ROLL_SOU,
|
||||
.priority = PRI_THR_ROLL_SOU,
|
||||
.stack = 2048,
|
||||
.tick = 20,
|
||||
.entry = chrg_roll_sou_thread_entry,
|
||||
}
|
||||
};
|
||||
|
||||
rt_err_t chrg_thread_mb_send (eIDX_THRS idx, void *data)
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
|
||||
if (idx >= TOTAL_THRS) {
|
||||
return RT_ERROR;
|
||||
}
|
||||
|
||||
struct chrg_thread_t *pTHR = &chrgthr[idx];
|
||||
|
||||
if (RT_NULL != pTHR->mb) {
|
||||
ret = rt_mb_send(pTHR->mb, (rt_uint32_t)data);
|
||||
if (RT_EOK != ret) {
|
||||
LOG_E("mb send failed. [%d]", ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int chrg_thread_create (eIDX_THRS idx)
|
||||
{
|
||||
if (idx >= TOTAL_THRS) {
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
struct chrg_thread_t *pTHR = &chrgthr[idx];
|
||||
|
||||
if (pTHR->mask & EN_THR_MUTEX) {
|
||||
pTHR->mutex = rt_mutex_create(pTHR->name, RT_IPC_FLAG_FIFO);
|
||||
if (RT_NULL == pTHR->mutex) {
|
||||
LOG_E("create mutex '%s' failed.", pTHR->name);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTHR->mask & EN_THR_SEM) {
|
||||
pTHR->sem = rt_sem_create(pTHR->name, 0, RT_IPC_FLAG_FIFO);
|
||||
if (RT_NULL == pTHR->sem) {
|
||||
LOG_E("create sem '%s' failed.", pTHR->sem);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTHR->mask & EN_THR_MAILBOX) {
|
||||
pTHR->mb = rt_mb_create(pTHR->name, 16, RT_IPC_FLAG_FIFO);
|
||||
if (RT_NULL == pTHR->mb) {
|
||||
LOG_E("create mb '%s' failed.", pTHR->name);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTHR->mask & EN_THR_EVENT) {
|
||||
pTHR->ev = rt_event_create(pTHR->name, RT_IPC_FLAG_FIFO);
|
||||
if (RT_NULL == pTHR->ev) {
|
||||
LOG_E("create ev '%s' failed.", pTHR->name);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTHR->mask & EN_THR_MQ) {
|
||||
pTHR->mq = rt_mq_create(pTHR->name, 32, 16, RT_IPC_FLAG_FIFO);
|
||||
if (RT_NULL == pTHR->mq) {
|
||||
LOG_E("create mq '%s' failed.", pTHR->name);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
pTHR->tid = rt_thread_create(pTHR->name, pTHR->entry, pTHR, pTHR->stack,
|
||||
pTHR->priority, pTHR->tick);
|
||||
if (RT_NULL != pTHR->tid) {
|
||||
rt_thread_startup(pTHR->tid);
|
||||
LOG_I("startup thread '%s'.", pTHR->name);
|
||||
} else {
|
||||
LOG_E("create thread '%s' failed.", pTHR->name);
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static int chrg_thread_init (void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < TOTAL_THRS; i++) {
|
||||
chrg_thread_create((eIDX_THRS)i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_APP_EXPORT(chrg_thread_init);
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
#ifndef __CHRG_THREAD_H__
|
||||
#define __CHRG_THREAD_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_north.h"
|
||||
#include "chrg_south.h"
|
||||
#include "chrg_comm.h"
|
||||
#include "chrg_lcd.h"
|
||||
#include "chrg_roll_nor.h"
|
||||
#include "chrg_roll_sou.h"
|
||||
|
||||
typedef enum {
|
||||
IDX_THR_NORTH = 0, // 北向接收线程
|
||||
IDX_THR_SOUTH, // 南向接收线程
|
||||
IDX_THR_COMM, // 对外通信线程
|
||||
IDX_THR_LCD, // LCD 接收线程
|
||||
IDX_THR_ROLL_NOR, // 北向轮巡发送线程
|
||||
IDX_THR_ROLL_SOU, // 南向轮巡发送线程
|
||||
|
||||
TOTAL_THRS
|
||||
} eIDX_THRS;
|
||||
|
||||
#define PRI_THR_NORTH 15
|
||||
#define PRI_THR_SOUTH 14
|
||||
#define PRI_THR_COMM 13
|
||||
#define PRI_THR_LCD 12
|
||||
#define PRI_THR_ROLL_NOR 16
|
||||
#define PRI_THR_ROLL_SOU 16
|
||||
|
||||
|
||||
#define EN_THR_NONE 0x00
|
||||
#define EN_THR_MUTEX 0x01 // 线程使用 锁
|
||||
#define EN_THR_SEM 0x02 // 线程使用 信号量
|
||||
#define EN_THR_MAILBOX 0x04 // 线程使用 邮箱
|
||||
#define EN_THR_EVENT 0x08 // 线程使用 事件
|
||||
#define EN_THR_MQ 0x10 // 线程使用 消息队列
|
||||
#define EN_THR_MASK (EN_THR_MUTEX|EN_THR_SEM|EN_THR_MAILBOX|EN_THR_EVENT|EN_THR_MQ)
|
||||
|
||||
/* 线程信息 */
|
||||
struct chrg_thread_t {
|
||||
const char *name; // 线程名
|
||||
struct rt_thread *tid; // 线程编号
|
||||
|
||||
rt_mutex_t mutex; // 锁
|
||||
rt_sem_t sem; // 信号量
|
||||
rt_mailbox_t mb; // 邮件
|
||||
rt_event_t ev; // 事件
|
||||
rt_mq_t mq; // 消息队列
|
||||
|
||||
rt_uint8_t mask; // use b0:lock b1:sem b2:mailbox b3:event b4:messagequeue
|
||||
|
||||
rt_uint8_t index; // 线程索引
|
||||
rt_uint8_t priority; // 优先级
|
||||
rt_uint32_t stack; // 堆栈大小
|
||||
rt_uint32_t tick; // 时间片
|
||||
|
||||
void (*entry)(void *parameter); // 线程体入口
|
||||
};
|
||||
|
||||
extern struct chrg_thread_t chrgthr[TOTAL_THRS];
|
||||
|
||||
extern rt_err_t chrg_thread_mb_send (eIDX_THRS idx, void *data);
|
||||
|
||||
extern int chrg_thread_create (eIDX_THRS idx);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,6 +38,12 @@ struct vc_pd_t {
|
||||
struct vc_mm_t mm[2]; // 电压电流极值
|
||||
};
|
||||
|
||||
/* 邮件内容 */
|
||||
struct mb_msg_t {
|
||||
rt_uint16_t length; // 数据长度
|
||||
rt_uint8_t *payload; // 数据区
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
int chrg_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
|
||||
rt_uint8_t len_in, rt_uint8_t *data_out, rt_uint16_t *len_out)
|
||||
{
|
||||
if ((RT_NULL == data_in)||(RT_NULL == data_out)||(0 == len_in)) {
|
||||
if (RT_NULL == data_out) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((len_in > 0) && (RT_NULL == data_in)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -18,7 +22,11 @@ int chrg_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
|
||||
data_out[1] = 0x00;
|
||||
data_out[2] = id;
|
||||
data_out[3] = cmd;
|
||||
memcpy(&data_out[4], data_in, len_in);
|
||||
|
||||
if (len_in > 0) {
|
||||
memcpy(&data_out[4], data_in, len_in);
|
||||
}
|
||||
|
||||
data_out[len_in+4] = calc_crc8(data_out, len_in+4);
|
||||
|
||||
*len_out = 5+len_in;
|
||||
@@ -27,8 +35,87 @@ int chrg_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
|
||||
}
|
||||
|
||||
|
||||
int chrg_pkg_decode (eIDX_ID id, rt_uint8_t *data)
|
||||
int chrg_pkg_decode (rt_uint8_t *data, rt_uint16_t length, struct chrg_switch_t *pSW)
|
||||
{
|
||||
if ((RT_NULL == data)||(RT_NULL == pSW)||(length < 5)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rt_uint8_t crc = calc_crc8(data, length - 1);
|
||||
if (crc != data[length - 1]) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
struct pkg_head_t *pH = (struct pkg_head_t *)data;
|
||||
|
||||
if (ID_SOURCE == pSW->id) {
|
||||
struct chrg_src_t *pS = &pSW->source;
|
||||
|
||||
switch (pH->cmd) {
|
||||
case SRC_CMD_GET_VOLTAGE: {
|
||||
struct get_vol_ack_t *pAck = (struct get_vol_ack_t *)data;
|
||||
pS->vc.voltage = pAck->voltage;
|
||||
pS->vc.version = pAck->version;
|
||||
// ?
|
||||
}
|
||||
break;
|
||||
|
||||
case SRC_CMD_GET_PROTOCOL: {
|
||||
struct get_pd_pro_ack_t *pAck = (struct get_pd_pro_ack_t *)data;
|
||||
pS->pd_get[0].src_type = pAck->type;
|
||||
pS->pd_get[0].pps_type = pAck->pps;
|
||||
pS->pd_get[0].mm[0].max_vol = pAck->vmax;
|
||||
pS->pd_get[0].mm[0].min_vol = pAck->vmin;
|
||||
pS->pd_get[0].mm[0].max_cur = pAck->curpwr;
|
||||
}
|
||||
break;
|
||||
|
||||
case SRC_CMD_SET_CC_LEVEL: {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case SRC_CMD_SET_PROTOCOL: {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (ID_SINK == pSW->id) {
|
||||
struct chrg_sink_t *pS = &pSW->sink;
|
||||
|
||||
switch (pH->cmd) {
|
||||
case SINK_CMD_GET_VOLTAGE: {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case SINK_CMD_GET_PD: {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case SINK_CMD_SET_CC: {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case SINK_CMD_SET_LEVEL: {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case SINK_CMD_SET_QC20: {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
|
||||
#include "chrg_tty.h"
|
||||
#include "chrg_def.h"
|
||||
#include "chrg_switch.h"
|
||||
|
||||
extern int chrg_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
|
||||
rt_uint8_t len_in, rt_uint8_t *data_out, rt_uint16_t *len_out);
|
||||
|
||||
extern int chrg_pkg_decode (eIDX_ID id, rt_uint8_t *data);
|
||||
extern int chrg_pkg_decode (rt_uint8_t *data, rt_uint16_t length, struct chrg_switch_t *pSW);
|
||||
|
||||
extern int chrg_pkg_send (eIDX_TTY idx, rt_uint8_t *data, rt_uint16_t len);
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "chrg_pkg.h"
|
||||
#include "chrg_utils.h"
|
||||
|
||||
|
||||
|
||||
int source_get_vc (rt_uint16_t vol, rt_uint16_t cur)
|
||||
{
|
||||
rt_uint16_t len = 0;
|
||||
@@ -19,65 +21,50 @@ int source_get_vc (rt_uint16_t vol, rt_uint16_t cur)
|
||||
|
||||
chrg_pkg_encode(ID_SOURCE, SRC_CMD_GET_VOLTAGE, data, 6, frame, &len);
|
||||
|
||||
return chrg_pkg_send(IDX_TTY_SOUTH, frame, len);
|
||||
return chrg_north_send(frame, len);
|
||||
}
|
||||
|
||||
void source_get_pd (void)
|
||||
int source_get_pd (void)
|
||||
{
|
||||
rt_size_t len = 0;
|
||||
rt_uint8_t data[8] = {0};
|
||||
rt_uint16_t len = 0;
|
||||
rt_uint8_t frame[16] = {0};
|
||||
|
||||
data[0] = 0x05;
|
||||
data[1] = 0x00;
|
||||
data[2] = ID_SOURCE;
|
||||
data[3] = SRC_CMD_GET_PROTOCOL;
|
||||
data[4] = calc_crc8(data, 4);
|
||||
chrg_pkg_encode(ID_SOURCE, SRC_CMD_GET_PROTOCOL, RT_NULL, 0, frame, &len);
|
||||
|
||||
len = 0x05;
|
||||
|
||||
chrg_north_send(data, len);
|
||||
return chrg_north_send(frame, len);
|
||||
}
|
||||
|
||||
void source_set_cc_lvl (rt_uint8_t lvl)
|
||||
int source_set_cc_lvl (rt_uint8_t lvl)
|
||||
{
|
||||
rt_size_t len = 0;
|
||||
rt_uint16_t len = 0;
|
||||
rt_uint8_t data[8] = {0};
|
||||
rt_uint8_t frame[16] = {0};
|
||||
|
||||
data[0] = 0x06;
|
||||
data[1] = 0x00;
|
||||
data[2] = ID_SOURCE;
|
||||
data[3] = SRC_CMD_SET_CC_LEVEL;
|
||||
data[4] = lvl;
|
||||
data[5] = calc_crc8(data, 5);
|
||||
data[0] = lvl;
|
||||
|
||||
len = 0x06;
|
||||
chrg_pkg_encode(ID_SOURCE, SRC_CMD_SET_CC_LEVEL, data, 1, frame, &len);
|
||||
|
||||
chrg_north_send(data, len);
|
||||
return chrg_north_send(frame, len);
|
||||
}
|
||||
|
||||
void source_set_pd (rt_uint8_t pro, rt_uint8_t src, rt_uint8_t pps,
|
||||
int source_set_pd (rt_uint8_t pro, rt_uint8_t src, rt_uint8_t pps,
|
||||
rt_uint16_t vmax, rt_uint16_t vmin, rt_int16_t max_cur)
|
||||
{
|
||||
rt_size_t len = 0;
|
||||
rt_uint8_t data[16] = {0};
|
||||
rt_uint16_t len = 0;
|
||||
rt_uint8_t data[8] = {0};
|
||||
rt_uint8_t frame[16] = {0};
|
||||
|
||||
data[0] = 0x0B;
|
||||
data[1] = 0x00;
|
||||
data[2] = ID_SOURCE;
|
||||
data[3] = SRC_CMD_SET_PROTOCOL;
|
||||
data[4] = pro;
|
||||
data[5] = src;
|
||||
data[6] = pps;
|
||||
data[0] = pro;
|
||||
data[1] = src;
|
||||
data[2] = pps;
|
||||
|
||||
u16_to_u8v(vmax, &data[7]);
|
||||
u16_to_u8v(vmin, &data[9]);
|
||||
u16_to_u8v(max_cur, &data[11]);
|
||||
u16_to_u8v(vmax, &data[3]);
|
||||
u16_to_u8v(vmin, &data[5]);
|
||||
u16_to_u8v(max_cur, &data[7]);
|
||||
|
||||
data[13] = calc_crc8(data, 13);
|
||||
chrg_pkg_encode(ID_SOURCE, SRC_CMD_SET_CC_LEVEL, data, 9, frame, &len);
|
||||
|
||||
len = 0x0E;
|
||||
|
||||
chrg_north_send(data, len);
|
||||
return chrg_north_send(frame, len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +62,49 @@ typedef enum {
|
||||
TOTAL_PROS
|
||||
} eSRC_PRO;
|
||||
|
||||
// 应答帧头
|
||||
struct pkg_head_t {
|
||||
rt_uint8_t length; // 帧长度
|
||||
rt_uint8_t blank; // 固定 0x00
|
||||
rt_uint8_t id; // ID 号
|
||||
rt_uint8_t cmd; // 指令
|
||||
};
|
||||
|
||||
// 读取变电压板电压 应答
|
||||
struct get_vol_ack_t {
|
||||
struct pkg_head_t head;
|
||||
rt_uint16_t voltage; // 0.01V
|
||||
rt_uint8_t qc_data[6]; // 快充指令
|
||||
rt_uint16_t version; // 版本
|
||||
rt_uint8_t reserve[6]; // 保留
|
||||
rt_uint8_t crc8;
|
||||
};
|
||||
|
||||
// 读取源端的PD协议数据 应答
|
||||
struct get_pd_pro_ack_t {
|
||||
struct pkg_head_t head;
|
||||
rt_uint8_t type; // 源类型 0:PD0 3:APD0
|
||||
rt_uint8_t pps; // PPS类型 0:SPR PPS 1:EPR AVS 2:SPR AVS
|
||||
rt_uint16_t vmin; // 最小电压 mV
|
||||
rt_uint16_t vmax; // 最大电压 mV
|
||||
rt_uint16_t curpwr; // 最大电流/功率 mA/W
|
||||
rt_uint8_t reserve[6]; // 保留 当pps=2时,vmin,vmax,curpwr
|
||||
rt_uint8_t crc8;
|
||||
};
|
||||
|
||||
// 设置CC线 应答
|
||||
struct set_cc_ack_t {
|
||||
struct pkg_head_t head;
|
||||
rt_uint8_t crc8;
|
||||
};
|
||||
|
||||
// 设置快充协议 应答
|
||||
struct set_qc_ack_t {
|
||||
struct pkg_head_t head;
|
||||
rt_uint8_t crc8;
|
||||
};
|
||||
|
||||
|
||||
struct src_vc_t {
|
||||
rt_uint16_t voltage; // 读取 0.01V
|
||||
rt_uint16_t set_voltage; // 设置电压 mV
|
||||
@@ -87,6 +130,13 @@ struct chrg_src_t {
|
||||
|
||||
extern int source_get_vc (rt_uint16_t vol, rt_uint16_t cur);
|
||||
|
||||
extern int source_get_pd (void);
|
||||
|
||||
extern int source_set_cc_lvl (rt_uint8_t lvl);
|
||||
|
||||
extern int source_set_pd (rt_uint8_t pro, rt_uint8_t src, rt_uint8_t pps,
|
||||
rt_uint16_t vmax, rt_uint16_t vmin, rt_int16_t max_cur);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+184
-169
@@ -337,9 +337,9 @@
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER, STM32F405xx, __CLK_TCK=RT_TICK_PER_SECOND, __STDC_LIMIT_MACROS, RT_USING_LIBC, __RTTHREAD__, RT_USING_ARMLIBC</Define>
|
||||
<Define>STM32F405xx, __CLK_TCK=RT_TICK_PER_SECOND, __STDC_LIMIT_MACROS, RT_USING_LIBC, USE_HAL_DRIVER, __RTTHREAD__, RT_USING_ARMLIBC</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>applications\bsp;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\drivers\phy;..\..\rt-thread\components\finsh;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\include;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\legacy\usb\usbdevice;applications\utils;board;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\libc\compilers\common\include;applications\thread;board\ports;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\libs\cmsis-core\Include;applications;board\CubeMX_Config\Inc;..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\drivers\include;.;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\components\fal\inc</IncludePath>
|
||||
<IncludePath>..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\drivers\smp_call;board\CubeMX_Config\Inc;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\components\libc\compilers\common\include;board\ports;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\libs\cmsis-core\Include;..\..\rt-thread\components\finsh;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\libc\compilers\common\extension;applications\thread;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\components\drivers\include;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\rt-thread\components\drivers\include;applications;..\..\rt-thread\components\drivers\phy;applications\bsp;..\..\rt-thread\components\drivers\include;board;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\legacy\usb\usbdevice;..\..\rt-thread\components\fal\inc;..\..\rt-thread\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\epoll;.;..\..\rt-thread\libcpu\arm\common;applications\utils;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\drivers\include</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -394,9 +394,9 @@
|
||||
<GroupName>Applications/bsp</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>chrg_vcom.c</FileName>
|
||||
<FileName>chrg_led.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_vcom.c</FilePath>
|
||||
<FilePath>applications\bsp\chrg_led.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_wdt.c</FileName>
|
||||
@@ -404,39 +404,44 @@
|
||||
<FilePath>applications\bsp\chrg_wdt.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_pin.c</FileName>
|
||||
<FileName>chrg_switch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_pin.c</FilePath>
|
||||
<FilePath>applications\bsp\chrg_switch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_fal.c</FileName>
|
||||
<FileName>chrg_vcom.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_fal.c</FilePath>
|
||||
<FilePath>applications\bsp\chrg_vcom.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_rel.c</FileName>
|
||||
<FileName>chrg_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_rel.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_tmr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_tmr.c</FilePath>
|
||||
<FilePath>applications\bsp\chrg_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_clk.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_clk.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_tmr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_tmr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_tty.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_tty.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_switch.c</FileName>
|
||||
<FileName>chrg_rel.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_switch.c</FilePath>
|
||||
<FilePath>applications\bsp\chrg_rel.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_fal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_fal.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
@@ -444,14 +449,14 @@
|
||||
<GroupName>Applications/thread</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>chrg_roll.c</FileName>
|
||||
<FileName>chrg_south.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_roll.c</FilePath>
|
||||
<FilePath>applications\thread\chrg_south.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_north.c</FileName>
|
||||
<FileName>chrg_roll_nor.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_north.c</FilePath>
|
||||
<FilePath>applications\thread\chrg_roll_nor.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_comm.c</FileName>
|
||||
@@ -459,15 +464,25 @@
|
||||
<FilePath>applications\thread\chrg_comm.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_south.c</FileName>
|
||||
<FileName>chrg_thread.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_south.c</FilePath>
|
||||
<FilePath>applications\thread\chrg_thread.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_roll_sou.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_roll_sou.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_lcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_lcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_north.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_north.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -1382,11 +1397,6 @@
|
||||
<Group>
|
||||
<GroupName>Fal</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>fal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\fal\src\fal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -1397,6 +1407,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\fal\src\fal_rtt.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\fal\src\fal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fal_partition.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -1407,16 +1422,16 @@
|
||||
<Group>
|
||||
<GroupName>Finsh</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>msh.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\finsh\msh.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>cmd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\finsh\cmd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>msh.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\finsh\msh.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>shell.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -2277,16 +2292,6 @@
|
||||
<Group>
|
||||
<GroupName>klibc</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>rt_vsscanf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\src\klibc\rt_vsscanf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>kerrno.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\src\klibc\kerrno.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>rt_vsnprintf_tiny.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -2297,6 +2302,16 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\src\klibc\kstring.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>rt_vsscanf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\src\klibc\rt_vsscanf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>kerrno.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\src\klibc\kerrno.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>kstdio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -2337,6 +2352,11 @@
|
||||
<Group>
|
||||
<GroupName>rt_usbd</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>usbdevice_core.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\legacy\usb\usbdevice\core\usbdevice_core.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usbdevice.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -2347,155 +2367,40 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\legacy\usb\usbdevice\class\cdc_vcom.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usbdevice_core.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\legacy\usb\usbdevice\core\usbdevice_core.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>STM32F4-CMSIS</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>system_stm32f4xx.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\system_stm32f4xx.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>startup_stm32f405xx.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\arm\startup_stm32f405xx.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_stm32f4xx.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\system_stm32f4xx.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>STM32F4-HAL</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cryp_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cryp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_crc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pccard.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cec.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_wwdg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cortex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ex.c</FileName>
|
||||
<FileName>stm32f4xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ramfunc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pcd_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_ll_usb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_ll_usb.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_hcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_hcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rng.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_iwdg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_iwdg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c</FilePath>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_dma_ex.c</FileName>
|
||||
@@ -2503,9 +2408,109 @@
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc.c</FileName>
|
||||
<FileName>stm32f4xx_hal_usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c</FilePath>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ramfunc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_iwdg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_iwdg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cec.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_ll_usb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_ll_usb.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_hcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_hcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_wwdg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_crc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pccard.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pcd_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rng.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_lptim.c</FileName>
|
||||
@@ -2513,9 +2518,19 @@
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr_ex.c</FileName>
|
||||
<FileName>stm32f4xx_hal_rcc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c</FilePath>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cryp_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
|
||||
Reference in New Issue
Block a user