Compare commits
3 Commits
0516210c95
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 249409457f | |||
| 9869835739 | |||
| cfad5acd82 |
@@ -1,8 +1,6 @@
|
||||
#ifndef __BSP_H__
|
||||
#define __BSP_H__
|
||||
|
||||
/* Voilet Bsp */
|
||||
#include "VoiletPort.h"
|
||||
/* Board */
|
||||
#include "Board.h"
|
||||
|
||||
|
||||
+25
-6
@@ -16,7 +16,23 @@
|
||||
typedef enum {
|
||||
false = 0,
|
||||
true = 1,
|
||||
} bool_t;
|
||||
} BOOL_MAP_T;
|
||||
|
||||
/* DI数字信号采集枚举 */
|
||||
enum {
|
||||
DI_OFF = 0,
|
||||
DI_ON
|
||||
};
|
||||
/* DO数字信号输出枚举 */
|
||||
enum {
|
||||
DO_OFF = 0,
|
||||
DO_ON
|
||||
};
|
||||
/* LED灯输出枚举 */
|
||||
enum {
|
||||
LED_OFF = 0,
|
||||
LED_ON
|
||||
};
|
||||
|
||||
/* Interrupt Irq */
|
||||
typedef struct {
|
||||
@@ -32,7 +48,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
GPIO_TypeDef *GpioPort;
|
||||
unsigned short GpioPin;
|
||||
unsigned char Irqn;
|
||||
// unsigned char Irqn;
|
||||
} GPIO_PERIPH_T;
|
||||
|
||||
typedef struct {
|
||||
@@ -181,6 +197,8 @@ typedef struct {
|
||||
#define GPIO111 {RCC_APB2PeriphClockCmd, RCC_APB2Periph_GPIOG, {GPIOG, GPIO_Pin_15}}
|
||||
#endif
|
||||
|
||||
#define GPIO_NULL {0, 0, {0, 0}}
|
||||
|
||||
/* COM */
|
||||
typedef struct {
|
||||
USART_TypeDef *UartId;
|
||||
@@ -194,12 +212,13 @@ typedef struct {
|
||||
} COM_MAP_T;
|
||||
|
||||
typedef struct {
|
||||
COM_MAP_T *ComX;
|
||||
GPIO_MAP_T TxPort;
|
||||
GPIO_MAP_T RxPort;
|
||||
GPIOSpeed_TypeDef Speed;
|
||||
COM_MAP_T *ComX; //串口外设
|
||||
GPIO_MAP_T TxPort; //发送端口
|
||||
GPIO_MAP_T RxPort; //接收端口
|
||||
GPIO_MAP_T TxRxEn; //收发使能
|
||||
}COM_CONFIG;
|
||||
|
||||
#define COM_NUM 5
|
||||
#ifdef USART1
|
||||
#define COM0 (&(COM_MAP_T){RCC_APB2PeriphClockCmd, RCC_APB2Periph_USART1, {USART1,USART1_IRQn}})
|
||||
#endif
|
||||
|
||||
+22
-4
@@ -25,8 +25,8 @@ const GPIO_CONFIG DO_PERIPH[] = {
|
||||
#endif
|
||||
//串口配置表
|
||||
const COM_CONFIG COM_PERIPH[] = {
|
||||
{COM0,.TxPort = GPIO9, .RxPort =GPIO10, .Speed = GPIO_Speed_50MHz},
|
||||
{COM1,.TxPort = GPIO2, .RxPort = GPIO3, .Speed = GPIO_Speed_50MHz},
|
||||
{COM0,.TxPort = GPIO9, .RxPort =GPIO10},
|
||||
{COM1,.TxPort = GPIO2, .RxPort = GPIO3,.TxRxEn = GPIO55},
|
||||
};
|
||||
|
||||
void BspExtraInit(void);
|
||||
@@ -78,8 +78,8 @@ void BspInit(void) {
|
||||
|
||||
//串口配置
|
||||
for (i = 0;i < ARRAY_LEN(COM_PERIPH);i++) {
|
||||
GpioConfig(&COM_PERIPH[i].TxPort, GPIO_Mode_AF_PP, COM_PERIPH[i].Speed);
|
||||
GpioConfig(&COM_PERIPH[i].RxPort, GPIO_Mode_IPU, COM_PERIPH[i].Speed);
|
||||
GpioConfig(&COM_PERIPH[i].TxPort, GPIO_Mode_AF_PP, GPIO_Speed_2MHz);
|
||||
GpioConfig(&COM_PERIPH[i].RxPort, GPIO_Mode_IPU, GPIO_Speed_2MHz);
|
||||
}
|
||||
|
||||
INTERRUPT_ENABLE
|
||||
@@ -157,6 +157,24 @@ void LedToggle(uint8_t Chnl)
|
||||
GpioSet(&LED_PERIPH[Chnl].GpioX,LED_ON);
|
||||
}
|
||||
}
|
||||
|
||||
void Rs485StdConfig(const COM_MAP_T *ComX,unsigned int Baud)
|
||||
{
|
||||
for (unsigned char i = 0;i < ARRAY_LEN(COM_PERIPH);i++) {
|
||||
if (ComX == COM_PERIPH[i].ComX) {
|
||||
if (COM_PERIPH[i].TxRxEn.ClockTree) {
|
||||
GpioSet(&COM_PERIPH[i].TxRxEn,Baud);
|
||||
}
|
||||
ComStdConfig(COM_PERIPH[i].ComX,Baud);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Rs485AdvConfig(const COM_MAP_T *ComX, uint32_t Baud, uint8_t DataBits, uint8_t StopBits, uint8_t Parity)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 重写Printf函数
|
||||
* @note void
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Bsp.h"
|
||||
|
||||
extern const COM_CONFIG COM_PERIPH[];
|
||||
|
||||
/**
|
||||
* @brief 初始化UART口外设的时钟
|
||||
* @note void
|
||||
@@ -92,3 +94,7 @@ void ComAdvConfig(const COM_MAP_T *ComX, uint32_t Baud, uint8_t DataBits, uint8_
|
||||
{
|
||||
ComInit(ComX, Baud, DataBits, StopBits, Parity);
|
||||
}
|
||||
|
||||
unsigned int CalcBaudTransIoSpeed(unsigned int Baud) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user