add uart i2c can
This commit is contained in:
+8
-2
@@ -242,7 +242,12 @@ CONFIG_RT_USING_SERIAL_V1=y
|
|||||||
CONFIG_RT_SERIAL_USING_DMA=y
|
CONFIG_RT_SERIAL_USING_DMA=y
|
||||||
CONFIG_RT_SERIAL_RB_BUFSZ=64
|
CONFIG_RT_SERIAL_RB_BUFSZ=64
|
||||||
# CONFIG_RT_USING_SERIAL_BYPASS is not set
|
# CONFIG_RT_USING_SERIAL_BYPASS is not set
|
||||||
# CONFIG_RT_USING_CAN is not set
|
CONFIG_RT_USING_CAN=y
|
||||||
|
# CONFIG_RT_CAN_USING_HDR is not set
|
||||||
|
# CONFIG_RT_CAN_USING_CANFD is not set
|
||||||
|
CONFIG_RT_CANMSG_BOX_SZ=16
|
||||||
|
CONFIG_RT_CANSND_BOX_NUM=1
|
||||||
|
CONFIG_RT_CANSND_MSG_TIMEOUT=100
|
||||||
# CONFIG_RT_USING_CPUTIME is not set
|
# CONFIG_RT_USING_CPUTIME is not set
|
||||||
CONFIG_RT_USING_I2C=y
|
CONFIG_RT_USING_I2C=y
|
||||||
# CONFIG_RT_I2C_DEBUG is not set
|
# CONFIG_RT_I2C_DEBUG is not set
|
||||||
@@ -1497,7 +1502,8 @@ CONFIG_BSP_USING_I2C1=y
|
|||||||
CONFIG_BSP_USING_I2C2=y
|
CONFIG_BSP_USING_I2C2=y
|
||||||
CONFIG_BSP_USING_I2C3=y
|
CONFIG_BSP_USING_I2C3=y
|
||||||
CONFIG_BSP_USING_I2C4=y
|
CONFIG_BSP_USING_I2C4=y
|
||||||
# CONFIG_BSP_USING_CAN is not set
|
CONFIG_BSP_USING_CAN=y
|
||||||
|
CONFIG_BSP_USING_CAN1=y
|
||||||
# CONFIG_BSP_USING_RNG is not set
|
# CONFIG_BSP_USING_RNG is not set
|
||||||
# CONFIG_BSP_USING_UDID is not set
|
# CONFIG_BSP_USING_UDID is not set
|
||||||
# end of On-chip Peripheral Drivers
|
# end of On-chip Peripheral Drivers
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#include "chrg_can.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct chrg_can_t chrgcan[TOTAL_CAN] = {
|
||||||
|
[IDX_CAN_1] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_CAN,
|
||||||
|
.index = IDX_CAN_1,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static rt_err_t chrg_can1_rx_callback(rt_device_t dev, rt_size_t size)
|
||||||
|
{
|
||||||
|
|
||||||
|
rt_sem_release(&chrgcan[IDX_CAN_1].rx_sem);
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void chrg_can_rx_thread (void *data)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
struct rt_can_msg rxmsg = {0};
|
||||||
|
struct chrg_can_t *pCAN = (struct chrg_can_t *)data;
|
||||||
|
|
||||||
|
if (RT_NULL == pCAN) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IDX_CAN_1 == pCAN->index) {
|
||||||
|
rt_device_set_rx_indicate(pCAN->dev, chrg_can1_rx_callback);
|
||||||
|
} else {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
//rxmsg.hdr = -1; // 直接从 uselist 链表读取数据
|
||||||
|
|
||||||
|
rt_sem_take(&pCAN->rx_sem, RT_WAITING_FOREVER);
|
||||||
|
|
||||||
|
rt_device_read(pCAN->dev, 0, &rxmsg, sizeof(rxmsg));
|
||||||
|
|
||||||
|
rt_kprintf("ID : %02x ", rxmsg.id);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
rt_kprintf("%02X ", rxmsg.data[i]);
|
||||||
|
}
|
||||||
|
rt_kprintf("\r\n", rxmsg.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int chrg_can_init (void)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
rt_err_t ret = 0;
|
||||||
|
rt_thread_t tid;
|
||||||
|
|
||||||
|
struct chrg_can_t *pCAN = RT_NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < TOTAL_CAN; i++) {
|
||||||
|
pCAN = &chrgcan[i];
|
||||||
|
|
||||||
|
pCAN->dev = rt_device_find(pCAN->name);
|
||||||
|
if (RT_NULL == pCAN->dev) {
|
||||||
|
rt_kprintf("dev '%s' not found.\r\n", pCAN->name);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_sem_init(&pCAN->rx_sem, pCAN->name, 0, RT_IPC_FLAG_FIFO);
|
||||||
|
|
||||||
|
ret = rt_device_open(pCAN->dev, RT_DEVICE_FLAG_INT_TX | RT_DEVICE_FLAG_INT_RX);
|
||||||
|
if (RT_EOK != ret) {
|
||||||
|
rt_kprintf("open '%s' failed.\r\n", pCAN->name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tid = rt_thread_create(pCAN->name, chrg_can_rx_thread, pCAN, 1024, 25, 10);
|
||||||
|
if (tid != RT_NULL) {
|
||||||
|
rt_thread_startup(tid);
|
||||||
|
} else {
|
||||||
|
rt_kprintf("create thread '%s' failed.\r\n", pCAN->name);
|
||||||
|
return -RT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
INIT_APP_EXPORT(chrg_can_init);
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef __CHRG_CAN_H__
|
||||||
|
#define __CHRG_CAN_H__
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#define DEV_NAME_CAN "can1"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IDX_CAN_1 = 0,
|
||||||
|
|
||||||
|
TOTAL_CAN
|
||||||
|
} eIDX_CAN;
|
||||||
|
|
||||||
|
struct chrg_can_t {
|
||||||
|
rt_device_t dev;
|
||||||
|
struct rt_semaphore rx_sem;
|
||||||
|
|
||||||
|
const char *name;
|
||||||
|
eIDX_CAN index;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct chrg_can_t chrgcan[TOTAL_CAN];
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
#include <rtthread.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#include "chrg_i2c.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct chrg_i2c_t chrgi2c[TOTAL_I2C] = {
|
||||||
|
[IDX_I2C_1] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_I2C1,
|
||||||
|
.slave = SLAVE_PCF8574_ADDR,
|
||||||
|
.index = IDX_I2C_1,
|
||||||
|
},
|
||||||
|
[IDX_I2C_2] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_I2C2,
|
||||||
|
.slave = SLAVE_PCF8574_ADDR,
|
||||||
|
.index = IDX_I2C_2,
|
||||||
|
},
|
||||||
|
[IDX_I2C_3] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_I2C3,
|
||||||
|
.slave = SLAVE_PCF8574_ADDR,
|
||||||
|
.index = IDX_I2C_3,
|
||||||
|
},
|
||||||
|
[IDX_I2C_4] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_I2C4,
|
||||||
|
.slave = SLAVE_PCF8574_ADDR,
|
||||||
|
.index = IDX_I2C_4,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rt_uint8_t i2c_read_byte(struct chrg_i2c_t *pI2C, rt_uint8_t addr)
|
||||||
|
{
|
||||||
|
rt_uint8_t data = 0;
|
||||||
|
rt_uint8_t buffer[2] = {0};
|
||||||
|
struct rt_i2c_msg msg;
|
||||||
|
|
||||||
|
buffer[0] = addr;
|
||||||
|
|
||||||
|
msg.addr = pI2C->slave;
|
||||||
|
msg.flags = RT_I2C_WR;
|
||||||
|
msg.buf = buffer;
|
||||||
|
msg.len = 1;
|
||||||
|
rt_i2c_transfer(pI2C->dev, &msg, 1);
|
||||||
|
|
||||||
|
msg.flags = RT_I2C_RD;
|
||||||
|
msg.buf = &data;
|
||||||
|
rt_i2c_transfer(pI2C->dev, &msg, 1);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_err_t i2c_write_byte(struct chrg_i2c_t *pI2C, rt_uint8_t addr, rt_uint8_t data)
|
||||||
|
{
|
||||||
|
rt_uint8_t buffer[2] = {0};
|
||||||
|
struct rt_i2c_msg msg;
|
||||||
|
|
||||||
|
buffer[0] = addr;
|
||||||
|
buffer[1] = data;
|
||||||
|
|
||||||
|
msg.addr = pI2C->slave;
|
||||||
|
msg.flags = RT_I2C_WR;
|
||||||
|
msg.buf = buffer;
|
||||||
|
msg.len = 2;
|
||||||
|
|
||||||
|
if (rt_i2c_transfer(pI2C->dev, &msg, 1) != 1) {
|
||||||
|
return RT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int chrg_i2c_init (void)
|
||||||
|
{
|
||||||
|
struct chrg_i2c_t *pI2C = RT_NULL;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < TOTAL_I2C; i++) {
|
||||||
|
pI2C = &chrgi2c[i];
|
||||||
|
pI2C->dev = (struct rt_i2c_bus_device *)rt_device_find(pI2C->name);
|
||||||
|
if (RT_NULL == pI2C->dev) {
|
||||||
|
rt_kprintf("dev '%s' not found.\r\n", pI2C->name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INIT_ENV_EXPORT(chrg_i2c_init);
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef __CHRG_I2C_H__
|
||||||
|
#define __CHRG_I2C_H__
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#define SLAVE_PCF8574_ADDR 0x40
|
||||||
|
|
||||||
|
#define DEV_NAME_I2C1 "i2c1"
|
||||||
|
#define DEV_NAME_I2C2 "i2c2"
|
||||||
|
#define DEV_NAME_I2C3 "i2c3"
|
||||||
|
#define DEV_NAME_I2C4 "i2c4"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IDX_I2C_1 = 0,
|
||||||
|
IDX_I2C_2 = 1,
|
||||||
|
IDX_I2C_3 = 2,
|
||||||
|
IDX_I2C_4 = 3,
|
||||||
|
|
||||||
|
TOTAL_I2C
|
||||||
|
} eIDX_I2C;
|
||||||
|
|
||||||
|
|
||||||
|
struct chrg_i2c_t {
|
||||||
|
struct rt_i2c_bus_device *dev;
|
||||||
|
const char *name;
|
||||||
|
rt_uint8_t slave; // slave chip addr
|
||||||
|
eIDX_I2C index;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct chrg_i2c_t chrgi2c[TOTAL_I2C];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#include "chrg_tty.h"
|
||||||
|
|
||||||
|
struct chrg_tty_t chrgtty[TOTAL_TTY] = {
|
||||||
|
[IDX_TTY_RS485] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_RS485,
|
||||||
|
.index = IDX_TTY_RS485,
|
||||||
|
},
|
||||||
|
[IDX_TTY_LCD] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_LCD,
|
||||||
|
.index = IDX_TTY_LCD,
|
||||||
|
},
|
||||||
|
[IDX_TTY_NORTH] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_NORTH,
|
||||||
|
.index = IDX_TTY_NORTH,
|
||||||
|
},
|
||||||
|
[IDX_TTY_SOUTH] = {
|
||||||
|
.dev = RT_NULL,
|
||||||
|
.name = DEV_NAME_SOUTH,
|
||||||
|
.index = IDX_TTY_SOUTH,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static rt_err_t chrg_rs485_tty_input (rt_device_t dev, rt_size_t size)
|
||||||
|
{
|
||||||
|
rt_err_t ret = RT_EOK;
|
||||||
|
struct chrg_tty_t *pTTY = &chrgtty[IDX_TTY_RS485];
|
||||||
|
|
||||||
|
pTTY->msg.dev = dev;
|
||||||
|
pTTY->msg.size = size;
|
||||||
|
|
||||||
|
ret = rt_mq_send(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t));
|
||||||
|
if (ret == -RT_EFULL) {
|
||||||
|
rt_kprintf("msg queue is full!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static rt_err_t chrg_lcd_tty_input (rt_device_t dev, rt_size_t size)
|
||||||
|
{
|
||||||
|
rt_err_t ret = RT_EOK;
|
||||||
|
struct chrg_tty_t *pTTY = &chrgtty[IDX_TTY_LCD];
|
||||||
|
|
||||||
|
pTTY->msg.dev = dev;
|
||||||
|
pTTY->msg.size = size;
|
||||||
|
|
||||||
|
ret = rt_mq_send(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t));
|
||||||
|
if (ret == -RT_EFULL) {
|
||||||
|
rt_kprintf("msg queue is full!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static rt_err_t chrg_north_tty_input (rt_device_t dev, rt_size_t size)
|
||||||
|
{
|
||||||
|
rt_err_t ret = RT_EOK;
|
||||||
|
struct chrg_tty_t *pTTY = &chrgtty[IDX_TTY_NORTH];
|
||||||
|
|
||||||
|
pTTY->msg.dev = dev;
|
||||||
|
pTTY->msg.size = size;
|
||||||
|
|
||||||
|
ret = rt_mq_send(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t));
|
||||||
|
if (ret == -RT_EFULL) {
|
||||||
|
rt_kprintf("msg queue is full!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static rt_err_t chrg_south_tty_input (rt_device_t dev, rt_size_t size)
|
||||||
|
{
|
||||||
|
rt_err_t ret = RT_EOK;
|
||||||
|
struct chrg_tty_t *pTTY = &chrgtty[IDX_TTY_SOUTH];
|
||||||
|
|
||||||
|
pTTY->msg.dev = dev;
|
||||||
|
pTTY->msg.size = size;
|
||||||
|
|
||||||
|
ret = rt_mq_send(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t));
|
||||||
|
if (ret == -RT_EFULL) {
|
||||||
|
rt_kprintf("msg queue is full!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void chrg_tty_recv_entry (void *data)
|
||||||
|
{
|
||||||
|
struct chrg_tty_t *pTTY = (struct chrg_tty_t *)data;
|
||||||
|
|
||||||
|
rt_err_t ret = RT_EOK;
|
||||||
|
rt_int32_t rx_len = 0;
|
||||||
|
rt_uint8_t rx_raw[RT_SERIAL_RB_BUFSZ];
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
rt_memset(&pTTY->msg, 0, sizeof(struct rx_msg_t));
|
||||||
|
|
||||||
|
ret = rt_mq_recv(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t), RT_WAITING_FOREVER);
|
||||||
|
if (ret == RT_EOK) {
|
||||||
|
rt_memset(rx_raw, 0, RT_SERIAL_RB_BUFSZ);
|
||||||
|
rx_len = rt_device_read(pTTY->msg.dev, 0, rx_raw, pTTY->msg.size);
|
||||||
|
if (rx_len > 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_err_t chrg_tty_thread (struct chrg_tty_t *pTTY)
|
||||||
|
{
|
||||||
|
rt_err_t ret = RT_EOK;
|
||||||
|
rt_thread_t tid_tty;
|
||||||
|
|
||||||
|
struct serial_configure cfg = {
|
||||||
|
.baud_rate = BAUD_RATE_115200,
|
||||||
|
.data_bits = DATA_BITS_8,
|
||||||
|
.stop_bits = STOP_BITS_1,
|
||||||
|
.parity = PARITY_NONE,
|
||||||
|
.bit_order = BIT_ORDER_LSB,
|
||||||
|
.invert = NRZ_NORMAL,
|
||||||
|
.bufsz = RT_SERIAL_RB_BUFSZ,
|
||||||
|
.flowcontrol = RT_SERIAL_FLOWCONTROL_NONE,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (RT_NULL == pTTY->dev) {
|
||||||
|
rt_kprintf("dev is null.\r\n");
|
||||||
|
return RT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_mq_init(&pTTY->mq_rx, pTTY->name, pTTY->pool_msg,
|
||||||
|
sizeof(struct rx_msg_t), sizeof(pTTY->pool_msg), RT_IPC_FLAG_FIFO);
|
||||||
|
|
||||||
|
ret = rt_device_open(pTTY->dev, RT_DEVICE_OFLAG_RDWR|RT_DEVICE_FLAG_INT_RX);
|
||||||
|
if (ret != RT_EOK) {
|
||||||
|
rt_kprintf("open '%s' failed.\r\n", pTTY->name);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = rt_device_control(pTTY->dev, RT_DEVICE_CTRL_CONFIG, &cfg);
|
||||||
|
if (ret != RT_EOK) {
|
||||||
|
rt_kprintf("control '%s' failed.\r\n", pTTY->name);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pTTY->index) {
|
||||||
|
case IDX_TTY_RS485:
|
||||||
|
rt_device_set_rx_indicate(pTTY->dev, chrg_rs485_tty_input);
|
||||||
|
break;
|
||||||
|
case IDX_TTY_LCD:
|
||||||
|
rt_device_set_rx_indicate(pTTY->dev, chrg_lcd_tty_input);
|
||||||
|
break;
|
||||||
|
case IDX_TTY_NORTH:
|
||||||
|
rt_device_set_rx_indicate(pTTY->dev, chrg_north_tty_input);
|
||||||
|
break;
|
||||||
|
case IDX_TTY_SOUTH:
|
||||||
|
rt_device_set_rx_indicate(pTTY->dev, chrg_south_tty_input);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return RT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
tid_tty = rt_thread_create(pTTY->name, chrg_tty_recv_entry,
|
||||||
|
pTTY, 4096, RT_MAIN_THREAD_PRIORITY+2, 20);
|
||||||
|
|
||||||
|
if (tid_tty != RT_NULL) {
|
||||||
|
rt_thread_startup(tid_tty);
|
||||||
|
} else {
|
||||||
|
rt_kprintf("create thread '%s' failed.\r\n", pTTY->name);
|
||||||
|
return -RT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chrg_tty_init (void)
|
||||||
|
{
|
||||||
|
struct chrg_tty_t *pTTY = RT_NULL;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < TOTAL_TTY; i++) {
|
||||||
|
if (IDX_TTY_RS485 == i) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pTTY = &chrgtty[i];
|
||||||
|
|
||||||
|
pTTY->dev = rt_device_find(pTTY->name);
|
||||||
|
if (RT_NULL == pTTY->dev) {
|
||||||
|
rt_kprintf("dev '%s' not found.\r\n", pTTY->name);
|
||||||
|
return RT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
chrg_tty_thread(pTTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
INIT_APP_EXPORT(chrg_tty_init);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#ifndef __CHRG_TTY_H__
|
||||||
|
#define __CHRG_TTY_H__
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#define DEV_NAME_RS485 "uart1"
|
||||||
|
#define DEV_NAME_LCD "uart2"
|
||||||
|
#define DEV_NAME_NORTH "uart3"
|
||||||
|
#define DEV_NAME_SOUTH "uart6"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IDX_TTY_RS485 = 0,
|
||||||
|
IDX_TTY_LCD = 1,
|
||||||
|
IDX_TTY_NORTH = 2,
|
||||||
|
IDX_TTY_SOUTH = 3,
|
||||||
|
|
||||||
|
TOTAL_TTY
|
||||||
|
} eIDX_TTY;
|
||||||
|
|
||||||
|
struct rx_msg_t {
|
||||||
|
rt_device_t dev;
|
||||||
|
rt_size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct chrg_tty_t {
|
||||||
|
rt_device_t dev;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
eIDX_TTY index;
|
||||||
|
rt_uint32_t len_rx;
|
||||||
|
rt_uint8_t buf_rx[RT_SERIAL_RB_BUFSZ];
|
||||||
|
|
||||||
|
struct rt_messagequeue mq_rx;
|
||||||
|
struct rx_msg_t msg;
|
||||||
|
rt_uint8_t pool_msg[1024];
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct chrg_tty_t chrgtty[TOTAL_TTY];
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "switch_north.h"
|
||||||
|
|
||||||
|
int switch_north_channel(eIDX_SW_NOR idx)
|
||||||
|
{
|
||||||
|
if (idx >= TOTAL_SW_NOR) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(idx) {
|
||||||
|
case IDX_SW_NOR_0:
|
||||||
|
rt_pin_write(PIN_SW_NORTH_A, PIN_LOW);
|
||||||
|
rt_pin_write(PIN_SW_NORTH_B, PIN_LOW);
|
||||||
|
break;
|
||||||
|
case IDX_SW_NOR_1:
|
||||||
|
rt_pin_write(PIN_SW_NORTH_A, PIN_LOW);
|
||||||
|
rt_pin_write(PIN_SW_NORTH_B, PIN_HIGH);
|
||||||
|
break;
|
||||||
|
case IDX_SW_NOR_2:
|
||||||
|
rt_pin_write(PIN_SW_NORTH_A, PIN_HIGH);
|
||||||
|
rt_pin_write(PIN_SW_NORTH_B, PIN_LOW);
|
||||||
|
break;
|
||||||
|
case IDX_SW_NOR_3:
|
||||||
|
rt_pin_write(PIN_SW_NORTH_A, PIN_HIGH);
|
||||||
|
rt_pin_write(PIN_SW_NORTH_B, PIN_HIGH);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
INIT_ENV_EXPORT(switch_north_pins_init);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef __SWITCH_NORTH_H__
|
||||||
|
#define __SWITCH_NORTH_H__
|
||||||
|
|
||||||
|
#include "drv_gpio.h"
|
||||||
|
|
||||||
|
// U14 switch
|
||||||
|
#define PIN_SW_NORTH_A GET_PIN(B, 0)
|
||||||
|
#define PIN_SW_NORTH_B GET_PIN(B, 1)
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IDX_SW_NOR_0 = 0, // to J3
|
||||||
|
IDX_SW_NOR_1 = 1, // to J4
|
||||||
|
IDX_SW_NOR_2 = 2, // to J9
|
||||||
|
IDX_SW_NOR_3 = 3, // to J10
|
||||||
|
|
||||||
|
TOTAL_SW_NOR
|
||||||
|
} eIDX_SW_NOR;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "switch_south.h"
|
||||||
|
|
||||||
|
int switch_south_lv1_channel(eIDX_SW_SOU_LV1 idx)
|
||||||
|
{
|
||||||
|
if (idx >= TOTAL_SW_SOU_LV1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(idx) {
|
||||||
|
case IDX_SW_SOU_LV1_0:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV1_A, PIN_LOW);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV1_B, PIN_LOW);
|
||||||
|
break;
|
||||||
|
case IDX_SW_SOU_LV1_1:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV1_A, PIN_LOW);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV1_B, PIN_HIGH);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int switch_south_lv2_1_channel(eIDX_SW_SOU_LV2_1 idx)
|
||||||
|
{
|
||||||
|
if (idx >= TOTAL_SW_SOU_LV2_1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(idx) {
|
||||||
|
case IDX_SW_SOU_LV2_1_0:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_A1, PIN_LOW);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_B1, PIN_LOW);
|
||||||
|
break;
|
||||||
|
case IDX_SW_SOU_LV2_1_1:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_A1, PIN_LOW);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_B1, PIN_HIGH);
|
||||||
|
break;
|
||||||
|
case IDX_SW_SOU_LV2_1_2:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_A1, PIN_HIGH);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_B1, PIN_LOW);
|
||||||
|
break;
|
||||||
|
case IDX_SW_SOU_LV2_1_3:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_A1, PIN_HIGH);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_B1, PIN_HIGH);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int switch_south_lv2_2_channel(eIDX_SW_SOU_LV2_2 idx)
|
||||||
|
{
|
||||||
|
if (idx >= TOTAL_SW_SOU_LV2_2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(idx) {
|
||||||
|
case IDX_SW_SOU_LV2_2_0:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_A2, PIN_LOW);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_B2, PIN_LOW);
|
||||||
|
break;
|
||||||
|
case IDX_SW_SOU_LV2_2_1:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_A2, PIN_LOW);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_B2, PIN_HIGH);
|
||||||
|
break;
|
||||||
|
case IDX_SW_SOU_LV2_2_2:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_A2, PIN_HIGH);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_B2, PIN_LOW);
|
||||||
|
break;
|
||||||
|
case IDX_SW_SOU_LV2_2_3:
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_A2, PIN_HIGH);
|
||||||
|
rt_pin_write(PIN_SW_SOUTH_LV2_B2, PIN_HIGH);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
INIT_ENV_EXPORT(switch_south_pins_init);
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#ifndef __SWITCH_SOUTH_H__
|
||||||
|
#define __SWITCH_SOUTH_H__
|
||||||
|
|
||||||
|
#include "drv_gpio.h"
|
||||||
|
|
||||||
|
// U23 switch
|
||||||
|
#define PIN_SW_SOUTH_LV1_A GET_PIN(C, 8)
|
||||||
|
#define PIN_SW_SOUTH_LV1_B GET_PIN(C, 9)
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IDX_SW_SOU_LV1_0 = 0, // to U24
|
||||||
|
IDX_SW_SOU_LV1_1 = 1, // to U25
|
||||||
|
|
||||||
|
TOTAL_SW_SOU_LV1
|
||||||
|
} eIDX_SW_SOU_LV1;
|
||||||
|
|
||||||
|
// U24 switch
|
||||||
|
#define PIN_SW_SOUTH_LV2_A1 GET_PIN(A, 15)
|
||||||
|
#define PIN_SW_SOUTH_LV2_B1 GET_PIN(C, 10)
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IDX_SW_SOU_LV2_1_0 = 0, // to J12
|
||||||
|
IDX_SW_SOU_LV2_1_1 = 1, // to J13
|
||||||
|
IDX_SW_SOU_LV2_1_2 = 2, // to J14
|
||||||
|
IDX_SW_SOU_LV2_1_3 = 3, // to J15
|
||||||
|
|
||||||
|
TOTAL_SW_SOU_LV2_1
|
||||||
|
} eIDX_SW_SOU_LV2_1;
|
||||||
|
|
||||||
|
// U25 switch
|
||||||
|
#define PIN_SW_SOUTH_LV2_A2 GET_PIN(C, 11)
|
||||||
|
#define PIN_SW_SOUTH_LV2_B2 GET_PIN(C, 12)
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IDX_SW_SOU_LV2_2_0 = 0, // to J16
|
||||||
|
IDX_SW_SOU_LV2_2_1 = 1, // to J17
|
||||||
|
IDX_SW_SOU_LV2_2_2 = 2, // to J18
|
||||||
|
IDX_SW_SOU_LV2_2_3 = 3, // to J19
|
||||||
|
|
||||||
|
TOTAL_SW_SOU_LV2_2
|
||||||
|
} eIDX_SW_SOU_LV2_2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -30,12 +30,12 @@ static int tmr_clk_init (void)
|
|||||||
timer_fd = rt_timer_create("tmr_clk", tmr_clk_callback,
|
timer_fd = rt_timer_create("tmr_clk", tmr_clk_callback,
|
||||||
&tmrclk, RT_TICK_PER_SECOND, RT_TIMER_FLAG_PERIODIC);
|
&tmrclk, RT_TICK_PER_SECOND, RT_TIMER_FLAG_PERIODIC);
|
||||||
if (timer_fd == RT_NULL) {
|
if (timer_fd == RT_NULL) {
|
||||||
//LOG_E("create tmr_clk");
|
//rt_kprintf("create tmr_clk.\r\n");
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
ret = rt_timer_start(timer_fd);
|
ret = rt_timer_start(timer_fd);
|
||||||
if (ret != RT_EOK) {
|
if (ret != RT_EOK) {
|
||||||
//LOG_E("start tmr_clk");
|
rt_kprintf("start tmr_clk failed.\r\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ static rt_int32_t tmr_pin_timer_start (ePIN_IDX index)
|
|||||||
pPIN, pPIN->tmr_millis_on, RT_TIMER_FLAG_ONE_SHOT);
|
pPIN, pPIN->tmr_millis_on, RT_TIMER_FLAG_ONE_SHOT);
|
||||||
|
|
||||||
if (pPIN->tmr_fd == RT_NULL) {
|
if (pPIN->tmr_fd == RT_NULL) {
|
||||||
//LOG_E("tmr '%s'", pPIN->tmr_name);
|
rt_kprintf("tmr create '%s' failed.\r\n", pPIN->tmr_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,8 +227,6 @@ static int tmr_pins_init (void)
|
|||||||
rt_pin_write(pPIN->pin_base, pPIN->pin_value);
|
rt_pin_write(pPIN->pin_base, pPIN->pin_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//LOG_I("I : set '%s'(%d) mode %d", pPIN->pin_name, pPIN->pin_base, pPIN->pin_mode);
|
|
||||||
|
|
||||||
tmr_pin_timer_start((ePIN_IDX)i);
|
tmr_pin_timer_start((ePIN_IDX)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
#include <rtthread.h>
|
|
||||||
#include <rtdevice.h>
|
|
||||||
|
|
||||||
static rt_device_t serial_usart2;
|
|
||||||
|
|
||||||
rt_err_t usart2_rx_irq(rt_device_t dev, rt_size_t size)
|
|
||||||
{
|
|
||||||
rt_kprintf("rx_irq\r\n");
|
|
||||||
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int usart2_open(void)
|
|
||||||
{
|
|
||||||
rt_err_t ret;
|
|
||||||
|
|
||||||
serial_usart2 = rt_device_find("uart2");
|
|
||||||
if (RT_NULL == serial_usart2) {
|
|
||||||
rt_kprintf("can't find usart2.\r\n");
|
|
||||||
return RT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = rt_device_open(serial_usart2, RT_DEVICE_OFLAG_RDWR|RT_DEVICE_FLAG_INT_RX);
|
|
||||||
if (RT_EOK != ret) {
|
|
||||||
rt_kprintf("open usart2 failed.\r\n");
|
|
||||||
return RT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct serial_configure uart2_set_parg={ \
|
|
||||||
BAUD_RATE_115200, /* 115200 bits/s */ \
|
|
||||||
DATA_BITS_8, /* 8 databits */ \
|
|
||||||
STOP_BITS_1, /* 1 stopbit */ \
|
|
||||||
PARITY_NONE, /* No parity */ \
|
|
||||||
BIT_ORDER_LSB, /* LSB first sent */ \
|
|
||||||
NRZ_NORMAL, /* Normal mode */ \
|
|
||||||
RT_SERIAL_RB_BUFSZ, /* Buffer size */ \
|
|
||||||
0 \
|
|
||||||
};
|
|
||||||
|
|
||||||
rt_device_control(serial_usart2, RT_DEVICE_CTRL_CONFIG, &uart2_set_parg);
|
|
||||||
|
|
||||||
rt_device_set_rx_indicate(serial_usart2, usart2_rx_irq);
|
|
||||||
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_APP_EXPORT(usart2_open);
|
|
||||||
|
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
/* #define HAL_ADC_MODULE_ENABLED */
|
/* #define HAL_ADC_MODULE_ENABLED */
|
||||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||||
/* #define HAL_CAN_MODULE_ENABLED */
|
#define HAL_CAN_MODULE_ENABLED
|
||||||
/* #define HAL_CRC_MODULE_ENABLED */
|
/* #define HAL_CRC_MODULE_ENABLED */
|
||||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||||
/* #define HAL_DAC_MODULE_ENABLED */
|
/* #define HAL_DAC_MODULE_ENABLED */
|
||||||
|
|||||||
@@ -79,21 +79,28 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
|||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
} else if(huart->Instance==UART4) {
|
} else if(huart->Instance==UART5) {
|
||||||
/* Peripheral clock enable */
|
/* Peripheral clock enable */
|
||||||
__HAL_RCC_UART4_CLK_ENABLE();
|
__HAL_RCC_UART5_CLK_ENABLE();
|
||||||
|
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
/**UART2 GPIO Configuration
|
/**UART5 GPIO Configuration
|
||||||
PC10 ------> UART4_TX
|
PC12 ------> UART5_TX
|
||||||
PC11 ------> UART4_RX
|
PD2 ------> UART5_RX
|
||||||
*/
|
*/
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
|
GPIO_InitStruct.Pin = GPIO_PIN_12;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
|
GPIO_InitStruct.Alternate = GPIO_AF8_UART5;
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF8_UART5;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
} else if(huart->Instance==USART6) {
|
} else if(huart->Instance==USART6) {
|
||||||
/* Peripheral clock enable */
|
/* Peripheral clock enable */
|
||||||
__HAL_RCC_USART6_CLK_ENABLE();
|
__HAL_RCC_USART6_CLK_ENABLE();
|
||||||
@@ -151,15 +158,16 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
|||||||
PB11 ------> USART3_RX
|
PB11 ------> USART3_RX
|
||||||
*/
|
*/
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
|
||||||
} else if(huart->Instance==UART4) {
|
} else if(huart->Instance==UART5) {
|
||||||
/* Peripheral clock disable */
|
/* Peripheral clock disable */
|
||||||
__HAL_RCC_UART4_CLK_DISABLE();
|
__HAL_RCC_UART5_CLK_DISABLE();
|
||||||
|
|
||||||
/**UART4 GPIO Configuration
|
/**UART5 GPIO Configuration
|
||||||
PC10 ------> UART4_TX
|
PC12 ------> UART5_TX
|
||||||
PC11 ------> UART4_RX
|
PD2 ------> UART5_RX
|
||||||
*/
|
*/
|
||||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11);
|
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12);
|
||||||
|
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
|
||||||
} else if(huart->Instance==USART6) {
|
} else if(huart->Instance==USART6) {
|
||||||
/* Peripheral clock disable */
|
/* Peripheral clock disable */
|
||||||
__HAL_RCC_USART6_CLK_DISABLE();
|
__HAL_RCC_USART6_CLK_DISABLE();
|
||||||
@@ -174,8 +182,55 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/**
|
||||||
|
* @brief CAN MSP Initialization
|
||||||
|
* This function configures the hardware resources used in this example
|
||||||
|
* @param hcan: CAN handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(hcan->Instance==CAN1) {
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
__HAL_RCC_CAN1_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
/**CAN1 GPIO Configuration
|
||||||
|
PA11 ------> CAN1_RX
|
||||||
|
PA12 ------> CAN1_TX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CAN MSP De-Initialization
|
||||||
|
* This function freeze the hardware resources used in this example
|
||||||
|
* @param hcan: CAN handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
|
||||||
|
{
|
||||||
|
if(hcan->Instance==CAN1){
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_CAN1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**CAN1 GPIO Configuration
|
||||||
|
PA11 ------> CAN1_RX
|
||||||
|
PA12 ------> CAN1_TX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|||||||
+225
-139
@@ -337,9 +337,9 @@
|
|||||||
<v6Rtti>0</v6Rtti>
|
<v6Rtti>0</v6Rtti>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define>RT_USING_ARMLIBC, RT_USING_LIBC, __RTTHREAD__, __STDC_LIMIT_MACROS, __CLK_TCK=RT_TICK_PER_SECOND, STM32F405xx, USE_HAL_DRIVER</Define>
|
<Define>USE_HAL_DRIVER, __CLK_TCK=RT_TICK_PER_SECOND, RT_USING_ARMLIBC, STM32F405xx, RT_USING_LIBC, __RTTHREAD__, __STDC_LIMIT_MACROS</Define>
|
||||||
<Undefine></Undefine>
|
<Undefine></Undefine>
|
||||||
<IncludePath>..\..\libs\freemodbus\modbus\include;..\..\rt-thread\include;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\modbus\tcp;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\drivers\smp_call;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\libc\compilers\common\include;..\..\libs\freemodbus\modbus\rtu;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\libcpu\arm\common;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;board;..\..\rt-thread\components\libc\posix\io\eventfd;.;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\modbus\ascii;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\drivers\phy;board\CubeMX_Config\Inc;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\libs\cmsis-core\Include;..\..\rt-thread\components\finsh;applications;..\..\rt-thread\components\libc\posix\io\poll;..\..\libs\freemodbus\port</IncludePath>
|
<IncludePath>..\..\rt-thread\components\drivers\include;.;..\..\libs\freemodbus\modbus\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\include;..\..\rt-thread\components\finsh;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\libcpu\arm\cortex-m4;board\CubeMX_Config\Inc;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\modbus\tcp;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\libs\freemodbus\modbus\ascii;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\modbus\rtu;..\..\rt-thread\components\drivers\phy;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\components\libc\compilers\common\include;..\..\libs\freemodbus\port;..\..\libs\cmsis-core\Include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\libs\stm32f4\STM32F4_HAL\Inc;applications;..\..\rt-thread\libcpu\arm\common;board</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Cads>
|
</Cads>
|
||||||
<Aads>
|
<Aads>
|
||||||
@@ -393,16 +393,36 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>applications\tmr_clk.c</FilePath>
|
<FilePath>applications\tmr_clk.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
|
||||||
<FileName>usart2.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>applications\usart2.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
<File>
|
||||||
<FileName>main.c</FileName>
|
<FileName>main.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>applications\main.c</FilePath>
|
<FilePath>applications\main.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>chrg_i2c.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>applications\chrg_i2c.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>switch_north.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>applications\switch_north.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>switch_south.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>applications\switch_south.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>chrg_tty.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>applications\chrg_tty.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>chrg_can.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>applications\chrg_can.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
@@ -453,6 +473,62 @@
|
|||||||
<Group>
|
<Group>
|
||||||
<GroupName>DeviceDrivers</GroupName>
|
<GroupName>DeviceDrivers</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
|
<File>
|
||||||
|
<FileName>dev_can.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\rt-thread\components\drivers\can\dev_can.c</FilePath>
|
||||||
|
<FileOption>
|
||||||
|
<CommonProperty>
|
||||||
|
<UseCPPCompiler>2</UseCPPCompiler>
|
||||||
|
<RVCTCodeConst>0</RVCTCodeConst>
|
||||||
|
<RVCTZI>0</RVCTZI>
|
||||||
|
<RVCTOtherData>0</RVCTOtherData>
|
||||||
|
<ModuleSelection>0</ModuleSelection>
|
||||||
|
<IncludeInBuild>1</IncludeInBuild>
|
||||||
|
<AlwaysBuild>0</AlwaysBuild>
|
||||||
|
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||||
|
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||||
|
<PublicsOnly>0</PublicsOnly>
|
||||||
|
<StopOnExitCode>3</StopOnExitCode>
|
||||||
|
<CustomArgument></CustomArgument>
|
||||||
|
<IncludeLibraryModules></IncludeLibraryModules>
|
||||||
|
<ComprImg>1</ComprImg>
|
||||||
|
</CommonProperty>
|
||||||
|
<FileArmAds>
|
||||||
|
<Cads>
|
||||||
|
<interw>2</interw>
|
||||||
|
<Optim>0</Optim>
|
||||||
|
<oTime>2</oTime>
|
||||||
|
<SplitLS>2</SplitLS>
|
||||||
|
<OneElfS>2</OneElfS>
|
||||||
|
<Strict>2</Strict>
|
||||||
|
<EnumInt>2</EnumInt>
|
||||||
|
<PlainCh>2</PlainCh>
|
||||||
|
<Ropi>2</Ropi>
|
||||||
|
<Rwpi>2</Rwpi>
|
||||||
|
<wLevel>0</wLevel>
|
||||||
|
<uThumb>2</uThumb>
|
||||||
|
<uSurpInc>2</uSurpInc>
|
||||||
|
<uC99>2</uC99>
|
||||||
|
<uGnu>2</uGnu>
|
||||||
|
<useXO>2</useXO>
|
||||||
|
<v6Lang>0</v6Lang>
|
||||||
|
<v6LangP>0</v6LangP>
|
||||||
|
<vShortEn>2</vShortEn>
|
||||||
|
<vShortWch>2</vShortWch>
|
||||||
|
<v6Lto>2</v6Lto>
|
||||||
|
<v6WtE>2</v6WtE>
|
||||||
|
<v6Rtti>2</v6Rtti>
|
||||||
|
<VariousControls>
|
||||||
|
<MiscControls> </MiscControls>
|
||||||
|
<Define>__RT_IPC_SOURCE__</Define>
|
||||||
|
<Undefine> </Undefine>
|
||||||
|
<IncludePath></IncludePath>
|
||||||
|
</VariousControls>
|
||||||
|
</Cads>
|
||||||
|
</FileArmAds>
|
||||||
|
</FileOption>
|
||||||
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>device.c</FileName>
|
<FileName>device.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
@@ -1308,6 +1384,11 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>board\board.c</FilePath>
|
<FilePath>board\board.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>drv_can.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_can.c</FilePath>
|
||||||
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>drv_gpio.c</FileName>
|
<FileName>drv_gpio.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
@@ -1359,14 +1440,24 @@
|
|||||||
<GroupName>FreeModbus</GroupName>
|
<GroupName>FreeModbus</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
<File>
|
||||||
<FileName>mbfuncholding.c</FileName>
|
<FileName>mbfuncdiag.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncholding.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncdiag.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>sample_mb_slave.c</FileName>
|
<FileName>mbrtu.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\samples\sample_mb_slave.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\rtu\mbrtu.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>mbfuncholding_m.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncholding_m.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>portevent_m.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\port\portevent_m.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>mbfuncinput.c</FileName>
|
<FileName>mbfuncinput.c</FileName>
|
||||||
@@ -1374,9 +1465,9 @@
|
|||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncinput.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncinput.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>portserial.c</FileName>
|
<FileName>mbfuncinput_m.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\port\portserial.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncinput_m.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>porttcp.c</FileName>
|
<FileName>porttcp.c</FileName>
|
||||||
@@ -1389,9 +1480,9 @@
|
|||||||
<FilePath>..\..\libs\freemodbus\modbus\rtu\mbrtu_m.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\rtu\mbrtu_m.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>port.c</FileName>
|
<FileName>portserial.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\port\port.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\port\portserial.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>user_mb_app_m.c</FileName>
|
<FileName>user_mb_app_m.c</FileName>
|
||||||
@@ -1399,24 +1490,44 @@
|
|||||||
<FilePath>..\..\libs\freemodbus\port\user_mb_app_m.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\port\user_mb_app_m.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>sample_mb_master.c</FileName>
|
<FileName>mbfunccoils.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\samples\sample_mb_master.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfunccoils.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>mbfuncholding_m.c</FileName>
|
<FileName>porttimer_m.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncholding_m.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\port\porttimer_m.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>mbrtu.c</FileName>
|
<FileName>mbfuncother.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\rtu\mbrtu.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncother.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>mbfuncinput_m.c</FileName>
|
<FileName>mbfuncdisc_m.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncinput_m.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncdisc_m.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>port.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\port\port.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>portserial_m.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\port\portserial_m.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>mbfuncholding.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncholding.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>mbfunccoils_m.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfunccoils_m.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>mb.c</FileName>
|
<FileName>mb.c</FileName>
|
||||||
@@ -1429,24 +1540,9 @@
|
|||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncdisc.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncdisc.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>mbfunccoils_m.c</FileName>
|
<FileName>mbcrc.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfunccoils_m.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\rtu\mbcrc.c</FilePath>
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>mbfuncdisc_m.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncdisc_m.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>porttimer_m.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\port\porttimer_m.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>mbutils.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbutils.c</FilePath>
|
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>porttimer.c</FileName>
|
<FileName>porttimer.c</FileName>
|
||||||
@@ -1454,50 +1550,35 @@
|
|||||||
<FilePath>..\..\libs\freemodbus\port\porttimer.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\port\porttimer.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>portserial_m.c</FileName>
|
<FileName>mb_m.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\port\portserial_m.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\modbus\mb_m.c</FilePath>
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>mbfunccoils.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfunccoils.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>mbfuncother.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncother.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>mbcrc.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\rtu\mbcrc.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>mbfuncdiag.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\functions\mbfuncdiag.c</FilePath>
|
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>user_mb_app.c</FileName>
|
<FileName>user_mb_app.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\port\user_mb_app.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\port\user_mb_app.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>sample_mb_slave.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\samples\sample_mb_slave.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>sample_mb_master.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\samples\sample_mb_master.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>mbutils.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\freemodbus\modbus\functions\mbutils.c</FilePath>
|
||||||
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>portevent.c</FileName>
|
<FileName>portevent.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\freemodbus\port\portevent.c</FilePath>
|
<FilePath>..\..\libs\freemodbus\port\portevent.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
|
||||||
<FileName>mb_m.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\modbus\mb_m.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>portevent_m.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\freemodbus\port\portevent_m.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
@@ -2349,14 +2430,9 @@
|
|||||||
<GroupName>klibc</GroupName>
|
<GroupName>klibc</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
<File>
|
||||||
<FileName>kerrno.c</FileName>
|
<FileName>kstring.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\rt-thread\src\klibc\kerrno.c</FilePath>
|
<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>
|
||||||
<File>
|
<File>
|
||||||
<FileName>kstdio.c</FileName>
|
<FileName>kstdio.c</FileName>
|
||||||
@@ -2369,9 +2445,14 @@
|
|||||||
<FilePath>..\..\rt-thread\src\klibc\rt_vsnprintf_tiny.c</FilePath>
|
<FilePath>..\..\rt-thread\src\klibc\rt_vsnprintf_tiny.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>kstring.c</FileName>
|
<FileName>rt_vsscanf.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\rt-thread\src\klibc\kstring.c</FilePath>
|
<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>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
@@ -2408,85 +2489,50 @@
|
|||||||
<Group>
|
<Group>
|
||||||
<GroupName>STM32F4-CMSIS</GroupName>
|
<GroupName>STM32F4-CMSIS</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
|
||||||
<FileName>startup_stm32f405xx.s</FileName>
|
|
||||||
<FileType>2</FileType>
|
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\arm\startup_stm32f405xx.s</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
<File>
|
||||||
<FileName>system_stm32f4xx.c</FileName>
|
<FileName>system_stm32f4xx.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\system_stm32f4xx.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\system_stm32f4xx.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>startup_stm32f405xx.s</FileName>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<FilePath>..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\arm\startup_stm32f405xx.s</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>STM32F4-HAL</GroupName>
|
<GroupName>STM32F4-HAL</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
<File>
|
||||||
<FileName>stm32f4xx_hal_crc.c</FileName>
|
<FileName>stm32f4xx_hal_can.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_can.c</FilePath>
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32f4xx_hal_i2c_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c_ex.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_i2c.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c.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_pwr_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_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>
|
||||||
<File>
|
<File>
|
||||||
<FileName>stm32f4xx_hal_rcc_ex.c</FileName>
|
<FileName>stm32f4xx_hal_rcc_ex.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c</FilePath>
|
||||||
</File>
|
</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_gpio.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c</FilePath>
|
||||||
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>stm32f4xx_hal_pwr.c</FileName>
|
<FileName>stm32f4xx_hal_pwr.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>stm32f4xx_hal_rng.c</FileName>
|
<FileName>stm32f4xx_hal_cortex.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.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_rcc.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.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>
|
||||||
<File>
|
<File>
|
||||||
<FileName>stm32f4xx_hal_dma_ex.c</FileName>
|
<FileName>stm32f4xx_hal_dma_ex.c</FileName>
|
||||||
@@ -2494,14 +2540,34 @@
|
|||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>stm32f4xx_hal.c</FileName>
|
<FileName>stm32f4xx_hal_pwr_ex.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>stm32f4xx_hal_cec.c</FileName>
|
<FileName>stm32f4xx_hal_rng.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>stm32f4xx_hal_i2c_ex.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c_ex.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_dma.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>stm32f4xx_hal_i2c.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>stm32f4xx_hal_cryp_ex.c</FileName>
|
<FileName>stm32f4xx_hal_cryp_ex.c</FileName>
|
||||||
@@ -2513,6 +2579,26 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c</FilePath>
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c</FilePath>
|
||||||
</File>
|
</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_cec.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.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_rcc.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
</Groups>
|
</Groups>
|
||||||
|
|||||||
@@ -149,6 +149,10 @@
|
|||||||
#define RT_USING_SERIAL_V1
|
#define RT_USING_SERIAL_V1
|
||||||
#define RT_SERIAL_USING_DMA
|
#define RT_SERIAL_USING_DMA
|
||||||
#define RT_SERIAL_RB_BUFSZ 64
|
#define RT_SERIAL_RB_BUFSZ 64
|
||||||
|
#define RT_USING_CAN
|
||||||
|
#define RT_CANMSG_BOX_SZ 16
|
||||||
|
#define RT_CANSND_BOX_NUM 1
|
||||||
|
#define RT_CANSND_MSG_TIMEOUT 100
|
||||||
#define RT_USING_I2C
|
#define RT_USING_I2C
|
||||||
#define RT_USING_I2C_BITOPS
|
#define RT_USING_I2C_BITOPS
|
||||||
#define RT_USING_PIN
|
#define RT_USING_PIN
|
||||||
@@ -470,6 +474,8 @@
|
|||||||
#define BSP_USING_I2C2
|
#define BSP_USING_I2C2
|
||||||
#define BSP_USING_I2C3
|
#define BSP_USING_I2C3
|
||||||
#define BSP_USING_I2C4
|
#define BSP_USING_I2C4
|
||||||
|
#define BSP_USING_CAN
|
||||||
|
#define BSP_USING_CAN1
|
||||||
/* end of On-chip Peripheral Drivers */
|
/* end of On-chip Peripheral Drivers */
|
||||||
|
|
||||||
/* Board extended module Drivers */
|
/* Board extended module Drivers */
|
||||||
|
|||||||
Reference in New Issue
Block a user