1.修改命名。

This commit is contained in:
MacRsh
2023-06-09 02:21:36 +08:00
parent 4b358b869d
commit 8bea355d15
4 changed files with 97 additions and 98 deletions

View File

@@ -26,14 +26,14 @@ static struct ch32_adc ch32_adc[] =
#endif
};
static struct mr_adc hw_adc[mr_array_get_length(ch32_adc)];
static struct mr_adc adc_driver[mr_array_get_length(ch32_adc)];
mr_err_t ch32_adc_configure(mr_adc_t adc, mr_uint8_t state)
{
struct ch32_adc *hw = (struct ch32_adc *)adc->device.data;
struct ch32_adc *driver = (struct ch32_adc *)adc->device.data;
ADC_InitTypeDef ADC_InitStructure = {0};
RCC_APB2PeriphClockCmd(hw->hw_adc.adc_periph_clock, (FunctionalState)state);
RCC_APB2PeriphClockCmd(driver->hw_adc.adc_periph_clock, (FunctionalState)state);
RCC_ADCCLKConfig(RCC_PCLK2_Div2);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
@@ -42,8 +42,8 @@ mr_err_t ch32_adc_configure(mr_adc_t adc, mr_uint8_t state)
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(hw->hw_adc.Instance, &ADC_InitStructure);
ADC_Cmd(hw->hw_adc.Instance, (FunctionalState)state);
ADC_Init(driver->hw_adc.Instance, &ADC_InitStructure);
ADC_Cmd(driver->hw_adc.Instance, (FunctionalState)state);
return MR_ERR_OK;
}
@@ -94,7 +94,7 @@ mr_err_t ch32_adc_channel_configure(mr_adc_t adc, struct mr_adc_config *config)
mr_uint32_t ch32_adc_read(mr_adc_t adc, mr_uint16_t channel)
{
struct ch32_adc *hw = (struct ch32_adc *)adc->device.data;
struct ch32_adc *driver = (struct ch32_adc *)adc->device.data;
mr_uint32_t data = 0;
if (channel > 17)
@@ -102,11 +102,11 @@ mr_uint32_t ch32_adc_read(mr_adc_t adc, mr_uint16_t channel)
return 0;
}
ADC_RegularChannelConfig(hw->hw_adc.Instance, channel, 1, ADC_SampleTime_239Cycles5);
ADC_SoftwareStartConvCmd(hw->hw_adc.Instance, ENABLE);
while (!ADC_GetFlagStatus(hw->hw_adc.Instance, ADC_FLAG_EOC));
data = ADC_GetConversionValue(hw->hw_adc.Instance);
ADC_ClearFlag(hw->hw_adc.Instance, ADC_FLAG_EOC);
ADC_RegularChannelConfig(driver->hw_adc.Instance, channel, 1, ADC_SampleTime_239Cycles5);
ADC_SoftwareStartConvCmd(driver->hw_adc.Instance, ENABLE);
while (!ADC_GetFlagStatus(driver->hw_adc.Instance, ADC_FLAG_EOC));
data = ADC_GetConversionValue(driver->hw_adc.Instance);
ADC_ClearFlag(driver->hw_adc.Instance, ADC_FLAG_EOC);
return data;
}
@@ -114,7 +114,7 @@ mr_uint32_t ch32_adc_read(mr_adc_t adc, mr_uint16_t channel)
mr_err_t ch32_adc_init(void)
{
mr_err_t ret = MR_ERR_OK;
mr_size_t count = mr_array_get_length(hw_adc);
mr_size_t count = mr_array_get_length(adc_driver);
static struct mr_adc_ops ops =
{
ch32_adc_configure,
@@ -124,7 +124,7 @@ mr_err_t ch32_adc_init(void)
while (count--)
{
ret = mr_adc_device_add(&hw_adc[count], ch32_adc[count].name, &ops, &ch32_adc[count]);
ret = mr_adc_device_add(&adc_driver[count], ch32_adc[count].name, &ops, &ch32_adc[count]);
MR_ASSERT(ret == MR_ERR_OK);
}

View File

@@ -26,16 +26,16 @@ static struct ch32_dac ch32_dac[] =
#endif
};
static struct mr_dac hw_dac[mr_array_get_length(ch32_dac)];
static struct mr_dac dac_driver[mr_array_get_length(ch32_dac)];
mr_err_t ch32_dac_configure(mr_dac_t dac, mr_uint8_t state)
{
struct ch32_dac *hw = (struct ch32_dac *)dac->device.data;
struct ch32_dac *driver = (struct ch32_dac *)dac->device.data;
DAC_InitTypeDef DAC_InitType = {0};
RCC_APB1PeriphClockCmd(hw->hw_dac.dac_periph_clock, (FunctionalState)state);
RCC_APB1PeriphClockCmd(driver->hw_dac.dac_periph_clock, (FunctionalState)state);
switch (hw->hw_dac.dac_channel)
switch (driver->hw_dac.dac_channel)
{
case DAC_Channel_1:
DAC_SetChannel1Data(DAC_Align_12b_R, 0);
@@ -52,20 +52,20 @@ mr_err_t ch32_dac_configure(mr_dac_t dac, mr_uint8_t state)
DAC_InitType.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitType.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0;
DAC_InitType.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
DAC_Init(hw->hw_dac.dac_channel, &DAC_InitType);
DAC_Cmd(hw->hw_dac.dac_channel, (FunctionalState)state);
DAC_Init(driver->hw_dac.dac_channel, &DAC_InitType);
DAC_Cmd(driver->hw_dac.dac_channel, (FunctionalState)state);
return MR_ERR_OK;
}
mr_err_t ch32_dac_channel_configure(mr_dac_t dac, struct mr_dac_config *config)
{
struct ch32_dac *hw = (struct ch32_dac *)dac->device.data;
struct ch32_dac *driver = (struct ch32_dac *)dac->device.data;
GPIO_InitTypeDef GPIO_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
switch (hw->hw_dac.dac_channel)
switch (driver->hw_dac.dac_channel)
{
case DAC_Channel_1:
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
@@ -88,9 +88,9 @@ mr_err_t ch32_dac_channel_configure(mr_dac_t dac, struct mr_dac_config *config)
void ch32_dac_write(mr_dac_t dac, mr_uint16_t channel, mr_uint32_t value)
{
struct ch32_dac *hw = (struct ch32_dac *)dac->device.data;
struct ch32_dac *driver = (struct ch32_dac *)dac->device.data;
switch (hw->hw_dac.dac_channel)
switch (driver->hw_dac.dac_channel)
{
case DAC_Channel_1:
DAC_SetChannel1Data(DAC_Align_12b_R, value);
@@ -106,7 +106,7 @@ void ch32_dac_write(mr_dac_t dac, mr_uint16_t channel, mr_uint32_t value)
mr_err_t ch32_dac_init(void)
{
mr_err_t ret = MR_ERR_OK;
mr_size_t count = mr_array_get_length(hw_dac);
mr_size_t count = mr_array_get_length(dac_driver);
static struct mr_dac_ops ops =
{
ch32_dac_configure,
@@ -116,13 +116,12 @@ mr_err_t ch32_dac_init(void)
while (count--)
{
ret = mr_dac_device_add(&hw_dac[count], ch32_dac[count].name, &ops, &ch32_dac[count]);
ret = mr_dac_device_add(&dac_driver[count], ch32_dac[count].name, &ops, &ch32_dac[count]);
MR_ASSERT(ret == MR_ERR_OK);
}
return MR_ERR_OK;
}
AUTO_INIT_DRIVER_EXPORT(ch32_dac_init);
#endif

View File

@@ -50,7 +50,7 @@ static struct ch32_spi ch32_spi[] =
#endif
};
static struct mr_spi_bus hw_spi[mr_array_get_length(ch32_spi)];
static struct mr_spi_bus spi_bus_driver[mr_array_get_length(ch32_spi)];
static mr_uint16_t ch32_spi_baud_rate_prescaler(mr_uint32_t pclk_freq, mr_uint32_t baud_rate)
{
@@ -77,7 +77,7 @@ static mr_uint16_t ch32_spi_baud_rate_prescaler(mr_uint32_t pclk_freq, mr_uint32
static mr_err_t ch32_spi_configure(mr_spi_bus_t spi_bus, struct mr_spi_config *config)
{
struct ch32_spi *hw = (struct ch32_spi *)spi_bus->device.data;
struct ch32_spi *driver = (struct ch32_spi *)spi_bus->device.data;
GPIO_InitTypeDef GPIO_InitStructure = {0};
SPI_InitTypeDef SPI_InitStructure = {0};
RCC_ClocksTypeDef RCC_ClockStruct = {0};
@@ -85,17 +85,17 @@ static mr_err_t ch32_spi_configure(mr_spi_bus_t spi_bus, struct mr_spi_config *c
RCC_GetClocksFreq(&RCC_ClockStruct);
if ((uint32_t)hw->hw_spi.Instance > APB2PERIPH_BASE)
if ((uint32_t)driver->hw_spi.Instance > APB2PERIPH_BASE)
{
RCC_APB2PeriphClockCmd(hw->hw_spi.spi_periph_clock, ENABLE);
RCC_APB2PeriphClockCmd(driver->hw_spi.spi_periph_clock, ENABLE);
pclk_freq = RCC_ClockStruct.PCLK2_Frequency;
}
else
{
RCC_APB1PeriphClockCmd(hw->hw_spi.spi_periph_clock, ENABLE);
RCC_APB1PeriphClockCmd(driver->hw_spi.spi_periph_clock, ENABLE);
pclk_freq = RCC_ClockStruct.PCLK1_Frequency;
}
RCC_APB2PeriphClockCmd(hw->hw_spi.gpio_periph_clock, ENABLE);
RCC_APB2PeriphClockCmd(driver->hw_spi.gpio_periph_clock, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
if (config->cs_active == MR_SPI_CS_ACTIVE_NONE)
@@ -148,69 +148,69 @@ static mr_err_t ch32_spi_configure(mr_spi_bus_t spi_bus, struct mr_spi_config *c
{
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
GPIO_InitStructure.GPIO_Pin = hw->hw_spi.clk_gpio_pin;
GPIO_InitStructure.GPIO_Pin = driver->hw_spi.clk_gpio_pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(hw->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_Init(driver->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = hw->hw_spi.miso_gpio_pin;
GPIO_InitStructure.GPIO_Pin = driver->hw_spi.miso_gpio_pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(hw->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_Init(driver->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = hw->hw_spi.mosi_gpio_pin;
GPIO_InitStructure.GPIO_Pin = driver->hw_spi.mosi_gpio_pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(hw->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_Init(driver->hw_spi.gpio_port, &GPIO_InitStructure);
}
else
{
SPI_InitStructure.SPI_Mode = SPI_Mode_Slave;
GPIO_InitStructure.GPIO_Pin = hw->hw_spi.clk_gpio_pin;
GPIO_InitStructure.GPIO_Pin = driver->hw_spi.clk_gpio_pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(hw->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_Init(driver->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = hw->hw_spi.miso_gpio_pin;
GPIO_InitStructure.GPIO_Pin = driver->hw_spi.miso_gpio_pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(hw->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_Init(driver->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = hw->hw_spi.mosi_gpio_pin;
GPIO_InitStructure.GPIO_Pin = driver->hw_spi.mosi_gpio_pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(hw->hw_spi.gpio_port, &GPIO_InitStructure);
GPIO_Init(driver->hw_spi.gpio_port, &GPIO_InitStructure);
}
SPI_InitStructure.SPI_BaudRatePrescaler = ch32_spi_baud_rate_prescaler(pclk_freq, config->baud_rate);
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_Init(hw->hw_spi.Instance, &SPI_InitStructure);
SPI_Cmd(hw->hw_spi.Instance, ENABLE);
SPI_Init(driver->hw_spi.Instance, &SPI_InitStructure);
SPI_Cmd(driver->hw_spi.Instance, ENABLE);
return MR_ERR_OK;
}
static mr_uint8_t ch32_spi_transfer(mr_spi_bus_t spi_bus, mr_uint8_t data)
{
struct ch32_spi *hw = (struct ch32_spi *)spi_bus->device.data;
struct ch32_spi *driver = (struct ch32_spi *)spi_bus->device.data;
mr_size_t i = 0;
while (SPI_I2S_GetFlagStatus(hw->hw_spi.Instance, SPI_I2S_FLAG_TXE) == RESET)
while (SPI_I2S_GetFlagStatus(driver->hw_spi.Instance, SPI_I2S_FLAG_TXE) == RESET)
{
i++;
if (i > 200)
{ return 0; }
}
SPI_I2S_SendData(hw->hw_spi.Instance, data);
SPI_I2S_SendData(driver->hw_spi.Instance, data);
while (SPI_I2S_GetFlagStatus(hw->hw_spi.Instance, SPI_I2S_FLAG_RXNE) == RESET)
while (SPI_I2S_GetFlagStatus(driver->hw_spi.Instance, SPI_I2S_FLAG_RXNE) == RESET)
{
i++;
if (i > 200)
{ return 0; }
}
return SPI_I2S_ReceiveData(hw->hw_spi.Instance);
return SPI_I2S_ReceiveData(driver->hw_spi.Instance);
}
static void ch32_spi_cs_crtl(mr_spi_bus_t spi_bus, mr_uint16_t cs_pin, mr_uint8_t state)
@@ -228,7 +228,7 @@ static void ch32_spi_cs_crtl(mr_spi_bus_t spi_bus, mr_uint16_t cs_pin, mr_uint8_
mr_err_t ch32_spi_init(void)
{
mr_err_t ret = MR_ERR_OK;
mr_size_t count = mr_array_get_length(hw_spi);
mr_size_t count = mr_array_get_length(spi_bus_driver);
static struct mr_spi_bus_ops ops =
{
ch32_spi_configure,
@@ -238,7 +238,7 @@ mr_err_t ch32_spi_init(void)
while (count--)
{
ret = mr_spi_bus_add(&hw_spi[count], ch32_spi[count].name, &ops, &ch32_spi[count]);
ret = mr_spi_bus_add(&spi_bus_driver[count], ch32_spi[count].name, &ops, &ch32_spi[count]);
MR_ASSERT(ret == MR_ERR_OK);
}

View File

@@ -140,39 +140,39 @@ static struct ch32_uart ch32_uart[] =
#endif
};
static struct mr_serial hw_serial[mr_array_get_length(ch32_uart)];
static struct mr_serial serial_driver[mr_array_get_length(ch32_uart)];
static mr_err_t ch32_serial_configure(mr_serial_t serial, struct mr_serial_config *config)
{
struct ch32_uart *hw = (struct ch32_uart *)serial->device.data;
struct ch32_uart *driver = (struct ch32_uart *)serial->device.data;
GPIO_InitTypeDef GPIO_InitStructure = {0};
NVIC_InitTypeDef NVIC_InitStructure = {0};
USART_InitTypeDef USART_InitStructure = {0};
if (config->baud_rate == 0)
{
if (hw->hw_uart.Instance == USART1)
if (driver->hw_uart.Instance == USART1)
{
RCC_APB2PeriphClockCmd(hw->hw_uart.uart_periph_clock, DISABLE);
RCC_APB2PeriphClockCmd(driver->hw_uart.uart_periph_clock, DISABLE);
}
else
{
RCC_APB1PeriphClockCmd(hw->hw_uart.uart_periph_clock, DISABLE);
RCC_APB1PeriphClockCmd(driver->hw_uart.uart_periph_clock, DISABLE);
}
RCC_APB2PeriphClockCmd(hw->hw_uart.gpio_periph_clock, DISABLE);
RCC_APB2PeriphClockCmd(driver->hw_uart.gpio_periph_clock, DISABLE);
return MR_ERR_OK;
}
if (hw->hw_uart.Instance == USART1)
if (driver->hw_uart.Instance == USART1)
{
RCC_APB2PeriphClockCmd(hw->hw_uart.uart_periph_clock, ENABLE);
RCC_APB2PeriphClockCmd(driver->hw_uart.uart_periph_clock, ENABLE);
}
else
{
RCC_APB1PeriphClockCmd(hw->hw_uart.uart_periph_clock, ENABLE);
RCC_APB1PeriphClockCmd(driver->hw_uart.uart_periph_clock, ENABLE);
}
RCC_APB2PeriphClockCmd(hw->hw_uart.gpio_periph_clock, ENABLE);
RCC_APB2PeriphClockCmd(driver->hw_uart.gpio_periph_clock, ENABLE);
switch (config->data_bits)
{
@@ -216,53 +216,53 @@ static mr_err_t ch32_serial_configure(mr_serial_t serial, struct mr_serial_confi
break;
}
if (hw->hw_uart.remap != CH32_UART_GPIO_REMAP_NONE)
if (driver->hw_uart.remap != CH32_UART_GPIO_REMAP_NONE)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
GPIO_PinRemapConfig(hw->hw_uart.remap, ENABLE);
GPIO_PinRemapConfig(driver->hw_uart.remap, ENABLE);
}
GPIO_InitStructure.GPIO_Pin = hw->hw_uart.tx_gpio_pin;
GPIO_InitStructure.GPIO_Pin = driver->hw_uart.tx_gpio_pin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(hw->hw_uart.tx_gpio_port, &GPIO_InitStructure);
GPIO_Init(driver->hw_uart.tx_gpio_port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = hw->hw_uart.rx_gpio_pin;
GPIO_InitStructure.GPIO_Pin = driver->hw_uart.rx_gpio_pin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(hw->hw_uart.rx_gpio_port, &GPIO_InitStructure);
GPIO_Init(driver->hw_uart.rx_gpio_port, &GPIO_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = hw->hw_uart.irqno;
NVIC_InitStructure.NVIC_IRQChannel = driver->hw_uart.irqno;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
USART_ITConfig(hw->hw_uart.Instance, USART_IT_RXNE, ENABLE);
USART_ITConfig(driver->hw_uart.Instance, USART_IT_RXNE, ENABLE);
USART_InitStructure.USART_BaudRate = config->baud_rate;
USART_InitStructure.USART_HardwareFlowControl = 0;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(hw->hw_uart.Instance, &USART_InitStructure);
USART_Cmd(hw->hw_uart.Instance, ENABLE);
USART_Init(driver->hw_uart.Instance, &USART_InitStructure);
USART_Cmd(driver->hw_uart.Instance, ENABLE);
return MR_ERR_OK;
}
static void ch32_serial_write(mr_serial_t serial, mr_uint8_t data)
{
struct ch32_uart *hw = (struct ch32_uart *)serial->device.data;
struct ch32_uart *driver = (struct ch32_uart *)serial->device.data;
while (USART_GetFlagStatus(hw->hw_uart.Instance, USART_FLAG_TC) == RESET);
hw->hw_uart.Instance->DATAR = data;
while (USART_GetFlagStatus(driver->hw_uart.Instance, USART_FLAG_TC) == RESET);
driver->hw_uart.Instance->DATAR = data;
}
static mr_uint8_t ch32_serial_read(mr_serial_t serial)
{
struct ch32_uart *hw = (struct ch32_uart *)serial->device.data;
struct ch32_uart *driver = (struct ch32_uart *)serial->device.data;
if (USART_GetFlagStatus(hw->hw_uart.Instance, USART_FLAG_RXNE) != RESET)
if (USART_GetFlagStatus(driver->hw_uart.Instance, USART_FLAG_RXNE) != RESET)
{
return hw->hw_uart.Instance->DATAR & 0xff;
return driver->hw_uart.Instance->DATAR & 0xff;
}
return 0;
@@ -270,32 +270,32 @@ static mr_uint8_t ch32_serial_read(mr_serial_t serial)
static void ch32_serial_start_tx(mr_serial_t serial)
{
struct ch32_uart *hw = (struct ch32_uart *)serial->device.data;
struct ch32_uart *driver = (struct ch32_uart *)serial->device.data;
USART_ITConfig(hw->hw_uart.Instance, USART_IT_TXE, ENABLE);
USART_ITConfig(driver->hw_uart.Instance, USART_IT_TXE, ENABLE);
}
static void ch32_serial_stop_tx(mr_serial_t serial)
{
struct ch32_uart *hw = (struct ch32_uart *)serial->device.data;
struct ch32_uart *driver = (struct ch32_uart *)serial->device.data;
USART_ITConfig(hw->hw_uart.Instance, USART_IT_TXE, DISABLE);
USART_ITConfig(driver->hw_uart.Instance, USART_IT_TXE, DISABLE);
}
static void ch32_serial_isr(mr_serial_t serial)
{
struct ch32_uart *hw = (struct ch32_uart *)serial->device.data;
struct ch32_uart *driver = (struct ch32_uart *)serial->device.data;
if (USART_GetITStatus(hw->hw_uart.Instance, USART_IT_RXNE) != RESET)
if (USART_GetITStatus(driver->hw_uart.Instance, USART_IT_RXNE) != RESET)
{
mr_serial_device_isr(serial, MR_SERIAL_EVENT_RX_INT);
USART_ClearITPendingBit(hw->hw_uart.Instance, USART_IT_RXNE);
USART_ClearITPendingBit(driver->hw_uart.Instance, USART_IT_RXNE);
}
if (USART_GetITStatus(hw->hw_uart.Instance, USART_IT_TXE) != RESET)
if (USART_GetITStatus(driver->hw_uart.Instance, USART_IT_TXE) != RESET)
{
mr_serial_device_isr(serial, MR_SERIAL_EVENT_TX_INT);
USART_ClearITPendingBit(hw->hw_uart.Instance, USART_IT_TXE);
USART_ClearITPendingBit(driver->hw_uart.Instance, USART_IT_TXE);
}
}
@@ -304,7 +304,7 @@ void USART1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void USART1_IRQHandler(void)
{
ch32_serial_isr(&hw_serial[UART1_INDEX]);
ch32_serial_isr(&serial_driver[UART1_INDEX]);
}
#endif
@@ -314,7 +314,7 @@ void USART2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void USART2_IRQHandler(void)
{
ch32_serial_isr(&hw_serial[UART2_INDEX]);
ch32_serial_isr(&serial_driver[UART2_INDEX]);
}
#endif
@@ -324,7 +324,7 @@ void USART3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void USART3_IRQHandler(void)
{
ch32_serial_isr(&hw_serial[UART3_INDEX]);
ch32_serial_isr(&serial_driver[UART3_INDEX]);
}
#endif
@@ -334,7 +334,7 @@ void UART4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART4_IRQHandler(void)
{
ch32_serial_isr(&hw_serial[UART4_INDEX]);
ch32_serial_isr(&serial_driver[UART4_INDEX]);
}
#endif
@@ -344,7 +344,7 @@ void UART5_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART5_IRQHandler(void)
{
ch32_serial_isr(&hw_serial[UART5_INDEX]);
ch32_serial_isr(&serial_driver[UART5_INDEX]);
}
#endif
@@ -354,7 +354,7 @@ void UART6_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART6_IRQHandler(void)
{
ch32_serial_isr(&hw_serial[UART6_INDEX]);
ch32_serial_isr(&serial_driver[UART6_INDEX]);
}
#endif
@@ -364,7 +364,7 @@ void UART7_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART7_IRQHandler(void)
{
ch32_serial_isr(&hw_serial[UART7_INDEX]);
ch32_serial_isr(&serial_driver[UART7_INDEX]);
}
#endif
@@ -374,7 +374,7 @@ void UART8_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART8_IRQHandler(void)
{
ch32_serial_isr(&hw_serial[UART8_INDEX]);
ch32_serial_isr(&serial_driver[UART8_INDEX]);
}
#endif
@@ -382,7 +382,7 @@ void UART8_IRQHandler(void)
mr_err_t ch32_uart_init(void)
{
mr_err_t ret = MR_ERR_OK;
mr_size_t count = mr_array_get_length(hw_serial);
mr_size_t count = mr_array_get_length(serial_driver);
static struct mr_serial_ops ops =
{
ch32_serial_configure,
@@ -394,7 +394,7 @@ mr_err_t ch32_uart_init(void)
while (count--)
{
ret = mr_serial_device_add(&hw_serial[count], ch32_uart[count].name, &ops, &ch32_uart[count]);
ret = mr_serial_device_add(&serial_driver[count], ch32_uart[count].name, &ops, &ch32_uart[count]);
MR_ASSERT(ret == MR_ERR_OK);
}