mirror of
https://github.com/HEYAHONG/ExtBoard-001.git
synced 2025-05-08 23:52:38 +08:00
整理代码,尝试添加串口中断发送
This commit is contained in:
parent
a55b96b344
commit
7fd9bf8eff
@ -183,13 +183,13 @@ static rt_err_t air32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ADC channel number is up to 17 */
|
||||
/* ADC channel number is up to 17 */
|
||||
#if !defined(ADC_CHANNEL_18)
|
||||
if (channel <= 17)
|
||||
/* ADC channel number is up to 19 */
|
||||
/* ADC channel number is up to 19 */
|
||||
#elif defined(ADC_CHANNEL_19)
|
||||
if (channel <= 19)
|
||||
/* ADC channel number is up to 18 */
|
||||
/* ADC channel number is up to 18 */
|
||||
#else
|
||||
if (channel <= 18)
|
||||
#endif
|
||||
@ -211,7 +211,7 @@ static rt_err_t air32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
|
||||
|
||||
ADC_ChanConf.Rank = 1;
|
||||
ADC_ChanConf.SamplingTime = ADC_SampleTime_239Cycles5;
|
||||
ADC_RegularChannelConfig(air32_adc_handler->Instance,ADC_ChanConf.Channel , ADC_ChanConf.Rank, ADC_ChanConf.SamplingTime );
|
||||
ADC_RegularChannelConfig(air32_adc_handler->Instance,ADC_ChanConf.Channel, ADC_ChanConf.Rank, ADC_ChanConf.SamplingTime );
|
||||
|
||||
/* start ADC */
|
||||
ADC_SoftwareStartConvCmd(air32_adc_handler->Instance, ENABLE);
|
||||
|
@ -321,9 +321,9 @@ static rt_err_t air32_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||
rt_base_t level;
|
||||
rt_int32_t irqindex = -1;
|
||||
rt_uint8_t gpio_port_souce=0;
|
||||
GPIO_InitTypeDef GPIO_InitStruct={0};
|
||||
NVIC_InitTypeDef NVIC_InitStructure={0};
|
||||
EXTI_InitTypeDef EXTI_InitStructure={0};
|
||||
GPIO_InitTypeDef GPIO_InitStruct= {0};
|
||||
NVIC_InitTypeDef NVIC_InitStructure= {0};
|
||||
EXTI_InitTypeDef EXTI_InitStructure= {0};
|
||||
|
||||
if (PIN_PORT(pin) >= PIN_AIRPORT_MAX)
|
||||
{
|
||||
@ -349,7 +349,7 @@ static rt_err_t air32_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||
irqmap = &pin_irq_map[irqindex];
|
||||
|
||||
/* Configure GPIO_InitStructure */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO , ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
|
||||
|
||||
/* Configure GPIO_InitStructure */
|
||||
GPIO_InitStruct.GPIO_Pin = PIN_AIRPIN(pin);
|
||||
|
@ -185,7 +185,7 @@ static rt_err_t air32_hwtimer_control(struct rt_hwtimer_device *device, rt_uint3
|
||||
}
|
||||
|
||||
static const struct rt_hwtimer_ops hwtimer_ops =
|
||||
{
|
||||
{
|
||||
.init = air32_hwtimer_init,
|
||||
.start = air32_hwtimer_start,
|
||||
.stop = air32_hwtimer_stop,
|
||||
|
@ -34,13 +34,15 @@ struct spi_bus_device
|
||||
|
||||
static struct spi_bus_device spi_bus_device_list[] = {
|
||||
#ifdef BSP_USING_SPI1
|
||||
{.periph = SPI1,
|
||||
.name = "spi1"},
|
||||
{ .periph = SPI1,
|
||||
.name = "spi1"
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_SPI2
|
||||
{.periph = SPI2,
|
||||
.name = "spi2"},
|
||||
{ .periph = SPI2,
|
||||
.name = "spi2"
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -290,7 +292,8 @@ static rt_ssize_t air32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mes
|
||||
|
||||
static struct rt_spi_ops spi_ops = {
|
||||
.configure = air32_spi_configure,
|
||||
.xfer = air32_spi_xfer};
|
||||
.xfer = air32_spi_xfer
|
||||
};
|
||||
|
||||
int rt_hw_spi_init(void)
|
||||
{
|
||||
|
@ -234,6 +234,7 @@ static rt_err_t air32_control(struct rt_serial_device *serial, int cmd, void *ar
|
||||
NVIC_Init(&NVIC_InitStruct);
|
||||
/* disable interrupt */
|
||||
USART_ITConfig(uart->config->Instance,USART_IT_RXNE,DISABLE);
|
||||
USART_ITConfig(uart->config->Instance,USART_IT_TC,DISABLE);
|
||||
|
||||
break;
|
||||
|
||||
@ -245,6 +246,7 @@ static rt_err_t air32_control(struct rt_serial_device *serial, int cmd, void *ar
|
||||
NVIC_Init(&NVIC_InitStruct);
|
||||
/* enable interrupt */
|
||||
USART_ITConfig(uart->config->Instance, USART_IT_RXNE,ENABLE);
|
||||
USART_ITConfig(uart->config->Instance, USART_IT_TC,ENABLE);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -293,7 +295,6 @@ static void uart_isr(struct rt_serial_device *serial)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = rt_container_of(serial, struct air32_uart, serial);
|
||||
|
||||
/* UART in mode Receiver -------------------------------------------------*/
|
||||
|
||||
if ((USART_GetITStatus(uart->config->Instance, USART_IT_RXNE) != RESET) && (RESET != USART_GetFlagStatus(uart->config->Instance, USART_FLAG_RXNE)))
|
||||
{
|
||||
@ -301,6 +302,12 @@ static void uart_isr(struct rt_serial_device *serial)
|
||||
USART_ClearITPendingBit(uart->config->Instance, USART_IT_RXNE);
|
||||
USART_ClearFlag(uart->config->Instance, USART_FLAG_RXNE);
|
||||
}
|
||||
else if ((USART_GetITStatus(uart->config->Instance, USART_IT_TC) != RESET) && (USART_GetFlagStatus(uart->config->Instance, USART_FLAG_TC) != RESET))
|
||||
{
|
||||
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_TX_DONE);
|
||||
USART_ClearITPendingBit(uart->config->Instance, USART_IT_TC);
|
||||
USART_ClearFlag(uart->config->Instance, USART_FLAG_TC);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (USART_GetFlagStatus(uart->config->Instance, USART_FLAG_CTS) != RESET)
|
||||
@ -312,11 +319,6 @@ static void uart_isr(struct rt_serial_device *serial)
|
||||
{
|
||||
USART_ClearFlag(uart->config->Instance, USART_FLAG_LBD);
|
||||
}
|
||||
|
||||
if (USART_GetFlagStatus(uart->config->Instance, USART_FLAG_TC) != RESET)
|
||||
{
|
||||
USART_ClearFlag(uart->config->Instance, USART_FLAG_TC);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -383,7 +383,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>DeviceDrivers</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
Loading…
x
Reference in New Issue
Block a user