|
@@ -23,7 +23,7 @@ void n32_msp_usart_init(void *Instance)
|
|
|
GPIO_InitStruct(&GPIO_InitCtlStruct);
|
|
|
GPIO_InitCtlStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
#ifdef BSP_USING_UART1
|
|
|
- if(USART1 == USARTx)
|
|
|
+ if (USART1 == USARTx)
|
|
|
{
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_USART1, ENABLE);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE);
|
|
@@ -37,7 +37,7 @@ void n32_msp_usart_init(void *Instance)
|
|
|
}
|
|
|
#endif
|
|
|
#ifdef BSP_USING_UART2
|
|
|
- if(USART2 == USARTx)
|
|
|
+ if (USART2 == USARTx)
|
|
|
{
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_USART2, ENABLE);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE);
|
|
@@ -51,7 +51,7 @@ void n32_msp_usart_init(void *Instance)
|
|
|
}
|
|
|
#endif
|
|
|
#ifdef BSP_USING_UART3
|
|
|
- if(USART3 == USARTx)
|
|
|
+ if (USART3 == USARTx)
|
|
|
{
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_USART3, ENABLE);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOB, ENABLE);
|
|
@@ -65,7 +65,7 @@ void n32_msp_usart_init(void *Instance)
|
|
|
}
|
|
|
#endif
|
|
|
#ifdef BSP_USING_UART4
|
|
|
- if(UART4 == USARTx)
|
|
|
+ if (UART4 == USARTx)
|
|
|
{
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_UART4, ENABLE);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOB, ENABLE);
|
|
@@ -91,7 +91,7 @@ void n32_msp_spi_init(void *Instance)
|
|
|
GPIO_InitStruct(&GPIO_InitCtlStruct);
|
|
|
GPIO_InitCtlStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
#ifdef BSP_USING_SPI1
|
|
|
- if(SPI1 == SPIx)
|
|
|
+ if (SPI1 == SPIx)
|
|
|
{
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_SPI1, ENABLE);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE);
|
|
@@ -108,7 +108,7 @@ void n32_msp_spi_init(void *Instance)
|
|
|
}
|
|
|
#endif
|
|
|
#ifdef BSP_USING_SPI2
|
|
|
- if(SPI2 == SPIx)
|
|
|
+ if (SPI2 == SPIx)
|
|
|
{
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_SPI2, ENABLE);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOB, ENABLE);
|
|
@@ -137,7 +137,7 @@ void n32_msp_sdio_init(void *Instance)
|
|
|
GPIO_InitStruct(&GPIO_InitCtlStructure);
|
|
|
GPIO_InitCtlStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
|
- if(SDIO == SDIOx)
|
|
|
+ if (SDIO == SDIOx)
|
|
|
{
|
|
|
/* if used dma ... */
|
|
|
RCC_EnableAHBPeriphClk(RCC_AHB_PERIPH_DMA2, ENABLE);
|
|
@@ -162,7 +162,7 @@ void n32_msp_tim_init(void *Instance)
|
|
|
GPIO_InitStruct(&GPIO_InitCtlStructure);
|
|
|
TIM_Module *TIMx = (TIM_Module *)Instance;
|
|
|
|
|
|
- if(TIMx == TIM1)
|
|
|
+ if (TIMx == TIM1)
|
|
|
{
|
|
|
/* TIM1 clock enable */
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_TIM1, ENABLE);
|
|
@@ -177,7 +177,7 @@ void n32_msp_tim_init(void *Instance)
|
|
|
GPIO_InitPeripheral(GPIOA, &GPIO_InitCtlStructure);
|
|
|
}
|
|
|
|
|
|
- if(TIMx == TIM2)
|
|
|
+ if (TIMx == TIM2)
|
|
|
{
|
|
|
/* TIM2 clock enable */
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM2, ENABLE);
|
|
@@ -192,12 +192,12 @@ void n32_msp_tim_init(void *Instance)
|
|
|
GPIO_InitPeripheral(GPIOA, &GPIO_InitCtlStructure);
|
|
|
}
|
|
|
|
|
|
- if(TIMx == TIM3)
|
|
|
+ if (TIMx == TIM3)
|
|
|
{
|
|
|
/* TIM3 clock enable */
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM3, ENABLE);
|
|
|
/* GPIOA clock enable */
|
|
|
- RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA|RCC_APB2_PERIPH_GPIOB, ENABLE);
|
|
|
+ RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA | RCC_APB2_PERIPH_GPIOB, ENABLE);
|
|
|
|
|
|
GPIO_InitCtlStructure.Pin = GPIO_PIN_6 | GPIO_PIN_7;
|
|
|
GPIO_InitCtlStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
|
@@ -218,15 +218,15 @@ void n32_msp_adc_init(void *Instance)
|
|
|
ADC_Module *ADCx = (ADC_Module *)Instance;
|
|
|
|
|
|
#ifdef BSP_USING_ADC1
|
|
|
- if(ADCx == ADC1)
|
|
|
+ if (ADCx == ADC1)
|
|
|
{
|
|
|
/* ADC1 & GPIO clock enable */
|
|
|
RCC_EnableAHBPeriphClk(RCC_AHB_PERIPH_ADC1, ENABLE);
|
|
|
- ADC_ConfigClk(ADC_CTRL3_CKMOD_AHB,RCC_ADCHCLK_DIV8);
|
|
|
+ ADC_ConfigClk(ADC_CTRL3_CKMOD_AHB, RCC_ADCHCLK_DIV8);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOC, ENABLE);
|
|
|
|
|
|
/* Configure ADC Channel as analog input */
|
|
|
- GPIO_InitCtlStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
|
|
|
+ GPIO_InitCtlStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3;
|
|
|
GPIO_InitCtlStruct.GPIO_Speed = GPIO_Speed_2MHz;
|
|
|
GPIO_InitCtlStruct.GPIO_Mode = GPIO_Mode_AIN;
|
|
|
GPIO_InitPeripheral(GPIOC, &GPIO_InitCtlStruct);
|
|
@@ -234,11 +234,11 @@ void n32_msp_adc_init(void *Instance)
|
|
|
#endif
|
|
|
|
|
|
#ifdef BSP_USING_ADC2
|
|
|
- if(ADCx == ADC2)
|
|
|
+ if (ADCx == ADC2)
|
|
|
{
|
|
|
/* ADC2 & GPIO clock enable */
|
|
|
RCC_EnableAHBPeriphClk(RCC_AHB_PERIPH_ADC2, ENABLE);
|
|
|
- ADC_ConfigClk(ADC_CTRL3_CKMOD_AHB,RCC_ADCHCLK_DIV8);
|
|
|
+ ADC_ConfigClk(ADC_CTRL3_CKMOD_AHB, RCC_ADCHCLK_DIV8);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOC, ENABLE);
|
|
|
|
|
|
/* Configure ADC Channel as analog input */
|
|
@@ -257,7 +257,7 @@ void n32_msp_hwtim_init(void *Instance)
|
|
|
TIM_Module *TIMx = (TIM_Module *)Instance;
|
|
|
|
|
|
#ifdef BSP_USING_HWTIM3
|
|
|
- if(TIMx == TIM3)
|
|
|
+ if (TIMx == TIM3)
|
|
|
{
|
|
|
/* TIM3 clock enable */
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM3, ENABLE);
|
|
@@ -265,7 +265,7 @@ void n32_msp_hwtim_init(void *Instance)
|
|
|
#endif
|
|
|
|
|
|
#ifdef BSP_USING_HWTIM4
|
|
|
- if(TIMx == TIM4)
|
|
|
+ if (TIMx == TIM4)
|
|
|
{
|
|
|
/* TIM4 clock enable */
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM4, ENABLE);
|
|
@@ -273,7 +273,7 @@ void n32_msp_hwtim_init(void *Instance)
|
|
|
#endif
|
|
|
|
|
|
#ifdef BSP_USING_HWTIM5
|
|
|
- if(TIMx == TIM5)
|
|
|
+ if (TIMx == TIM5)
|
|
|
{
|
|
|
/* TIM5 clock enable */
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM5, ENABLE);
|
|
@@ -281,19 +281,19 @@ void n32_msp_hwtim_init(void *Instance)
|
|
|
#endif
|
|
|
|
|
|
#ifdef BSP_USING_HWTIM6
|
|
|
- if(TIMx == TIM6)
|
|
|
- {
|
|
|
- /* TIM6 clock enable */
|
|
|
- RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM6, ENABLE);
|
|
|
- }
|
|
|
+ if (TIMx == TIM6)
|
|
|
+ {
|
|
|
+ /* TIM6 clock enable */
|
|
|
+ RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM6, ENABLE);
|
|
|
+ }
|
|
|
#endif
|
|
|
|
|
|
#ifdef BSP_USING_HWTIM7
|
|
|
- if(TIMx == TIM7)
|
|
|
- {
|
|
|
- /* TIM7 clock enable */
|
|
|
- RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM7, ENABLE);
|
|
|
- }
|
|
|
+ if (TIMx == TIM7)
|
|
|
+ {
|
|
|
+ /* TIM7 clock enable */
|
|
|
+ RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM7, ENABLE);
|
|
|
+ }
|
|
|
#endif
|
|
|
}
|
|
|
#endif
|
|
@@ -307,7 +307,7 @@ void n32_msp_can_init(void *Instance)
|
|
|
GPIO_InitStruct(&GPIO_InitCtlStruct);
|
|
|
GPIO_InitCtlStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
#ifdef BSP_USING_CAN1
|
|
|
- if(CAN1 == CANx)
|
|
|
+ if (CAN1 == CANx)
|
|
|
{
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_CAN1, ENABLE);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE);
|
|
@@ -321,7 +321,7 @@ void n32_msp_can_init(void *Instance)
|
|
|
}
|
|
|
#endif
|
|
|
#ifdef BSP_USING_CAN2
|
|
|
- if(CAN2 == CANx)
|
|
|
+ if (CAN2 == CANx)
|
|
|
{
|
|
|
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_CAN2, ENABLE);
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_AFIO, ENABLE);
|
|
@@ -347,7 +347,7 @@ static void uart_test_rw(rt_device_t uartx, const char *name)
|
|
|
if (uartx == NULL)
|
|
|
{
|
|
|
uartx = rt_device_find(name);
|
|
|
- rt_err_t err = rt_device_open(uartx, RT_DEVICE_FLAG_INT_RX|RT_DEVICE_FLAG_DMA_RX);
|
|
|
+ rt_err_t err = rt_device_open(uartx, RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_DMA_RX);
|
|
|
RT_ASSERT(err == RT_EOK);
|
|
|
}
|
|
|
rt_device_write(uartx, 0, name, strlen(name));
|
|
@@ -356,7 +356,7 @@ static void uart_test_rw(rt_device_t uartx, const char *name)
|
|
|
int ret = rt_device_read(uartx, 0, recv_buf, sizeof(recv_buf));
|
|
|
if (ret != 0)
|
|
|
{
|
|
|
- for (int i=0; i<ret; ++i)
|
|
|
+ for (int i = 0; i < ret; ++i)
|
|
|
rt_kprintf("[%02x]", recv_buf[i]);
|
|
|
}
|
|
|
rt_device_write(uartx, 0, "\r\n", 2);
|
|
@@ -377,9 +377,9 @@ MSH_CMD_EXPORT(uart_test, uart_test)
|
|
|
|
|
|
#ifdef BSP_USING_ADC
|
|
|
#ifdef BSP_USING_ADC1
|
|
|
-#define ADC_DEV_NAME "adc1"
|
|
|
+ #define ADC_DEV_NAME "adc1"
|
|
|
#else
|
|
|
-#define ADC_DEV_NAME "adc2"
|
|
|
+ #define ADC_DEV_NAME "adc2"
|
|
|
#endif
|
|
|
#define REFER_VOLTAGE 3300
|
|
|
#define CONVERT_BITS (1 << 12)
|
|
@@ -396,7 +396,7 @@ static int adc_vol_sample(int argc, char *argv[])
|
|
|
return RT_ERROR;
|
|
|
}
|
|
|
|
|
|
- for (int i=6; i<=9; ++i)
|
|
|
+ for (int i = 6; i <= 9; ++i)
|
|
|
{
|
|
|
ret = rt_adc_enable(adc_dev, i);
|
|
|
value = rt_adc_read(adc_dev, i);
|