forked from xuos/xiuos
fix: fix ch32v307 cannot enter shell
This commit is contained in:
parent
093f362387
commit
402f25a2fd
|
@ -20,10 +20,8 @@ Modification:
|
|||
#include "board.h"
|
||||
#include <xs_isr.h>
|
||||
|
||||
|
||||
|
||||
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void NMI_Handler(void) __attribute__((interrupt()));
|
||||
void HardFault_Handler(void) __attribute__((interrupt()));
|
||||
|
||||
/*********************************************************************
|
||||
* @fn NMI_Handler
|
||||
|
@ -56,6 +54,3 @@ void HardFault_Handler(void)
|
|||
isrManager.done->decCounter();
|
||||
FREE_INT_SP();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
extern void KTaskOsAssignAfterIrq(void *);
|
||||
|
||||
void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void SysTick_Handler(void) __attribute__((interrupt()));
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
GET_INT_SP();
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
* @date 2022-08-01
|
||||
*/
|
||||
|
||||
#include <xizi.h>
|
||||
#include "ch32v30x.h"
|
||||
#include "xsconfig.h"
|
||||
#include "connect_uart.h"
|
||||
#include "ch32v30x.h"
|
||||
#include "ch32v30x_usart.h"
|
||||
#include "xsconfig.h"
|
||||
#include <xizi.h>
|
||||
|
||||
/* uart driver */
|
||||
|
||||
|
@ -68,8 +68,7 @@ static void UartIsr(struct SerialDriver *serial_drv, struct SerialHardwareDevice
|
|||
{
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_drv->private_data;
|
||||
|
||||
if (RESET != USART_GetITStatus((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE))
|
||||
{
|
||||
if (RESET != USART_GetITStatus((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE)) {
|
||||
SerialSetIsr(serial_dev, SERIAL_EVENT_RX_IND);
|
||||
USART_ClearITPendingBit((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE);
|
||||
}
|
||||
|
@ -109,8 +108,7 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
|||
USART_InitTypeDef USART_InitStructure;
|
||||
USART_InitStructure.USART_BaudRate = serial_cfg->data_cfg.serial_baud_rate;
|
||||
|
||||
switch (serial_cfg->data_cfg.serial_data_bits)
|
||||
{
|
||||
switch (serial_cfg->data_cfg.serial_data_bits) {
|
||||
case DATA_BITS_8:
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
break;
|
||||
|
@ -123,8 +121,7 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
|||
break;
|
||||
}
|
||||
|
||||
switch (serial_cfg->data_cfg.serial_stop_bits)
|
||||
{
|
||||
switch (serial_cfg->data_cfg.serial_stop_bits) {
|
||||
case STOP_BITS_1:
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
break;
|
||||
|
@ -136,8 +133,7 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
|||
break;
|
||||
}
|
||||
|
||||
switch (serial_cfg->data_cfg.serial_parity_mode)
|
||||
{
|
||||
switch (serial_cfg->data_cfg.serial_parity_mode) {
|
||||
case PARITY_NONE:
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
break;
|
||||
|
@ -160,7 +156,6 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
|||
// usart_hardware_flow_rts_config(serial_cfg->hw_cfg.serial_register_base, USART_RTS_DISABLE);
|
||||
// usart_hardware_flow_cts_config(serial_cfg->hw_cfg.serial_register_base, USART_CTS_DISABLE);
|
||||
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
|
@ -170,8 +165,7 @@ static uint32 SerialConfigure(struct SerialDriver *serial_drv, int serial_operat
|
|||
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_drv->private_data;
|
||||
|
||||
switch (serial_operation_cmd)
|
||||
{
|
||||
switch (serial_operation_cmd) {
|
||||
case OPER_CLR_INT:
|
||||
NVIC_DisableIRQ(serial_cfg->hw_cfg.serial_irq_interrupt);
|
||||
USART_ITConfig((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE, DISABLE);
|
||||
|
@ -195,8 +189,7 @@ static uint32 SerialDrvConfigure(void *drv, struct BusConfigureInfo *configure_i
|
|||
int serial_operation_cmd;
|
||||
struct SerialDriver* serial_drv = (struct SerialDriver*)drv;
|
||||
|
||||
switch (configure_info->configure_cmd)
|
||||
{
|
||||
switch (configure_info->configure_cmd) {
|
||||
case OPE_INT:
|
||||
ret = SerialInit(serial_drv, configure_info);
|
||||
break;
|
||||
|
@ -215,7 +208,8 @@ static int SerialPutChar(struct SerialHardwareDevice *serial_dev, char c)
|
|||
{
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_dev->private_data;
|
||||
|
||||
while (USART_GetFlagStatus((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_TXE) == RESET);
|
||||
while (USART_GetFlagStatus((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_TXE) == RESET)
|
||||
;
|
||||
USART_SendData((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, (uint8_t)c);
|
||||
return 0;
|
||||
}
|
||||
|
@ -225,16 +219,14 @@ static int SerialGetChar(struct SerialHardwareDevice *serial_dev)
|
|||
int ch = -1;
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_dev->private_data;
|
||||
|
||||
if (RESET != USART_GetFlagStatus((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_RXNE))
|
||||
{
|
||||
if (RESET != USART_GetFlagStatus((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_RXNE)) {
|
||||
ch = USART_ReceiveData((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base) & 0xff;
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static const struct SerialDataCfg data_cfg_init =
|
||||
{
|
||||
static const struct SerialDataCfg data_cfg_init = {
|
||||
.serial_baud_rate = BAUD_RATE_115200,
|
||||
.serial_data_bits = DATA_BITS_8,
|
||||
.serial_stop_bits = STOP_BITS_1,
|
||||
|
@ -246,15 +238,13 @@ static const struct SerialDataCfg data_cfg_init =
|
|||
};
|
||||
|
||||
/*manage the serial device operations*/
|
||||
static const struct SerialDrvDone drv_done =
|
||||
{
|
||||
static const struct SerialDrvDone drv_done = {
|
||||
.init = SerialInit,
|
||||
.configure = SerialConfigure,
|
||||
};
|
||||
|
||||
/*manage the serial device hal operations*/
|
||||
static struct SerialHwDevDone hwdev_done =
|
||||
{
|
||||
static struct SerialHwDevDone hwdev_done = {
|
||||
.put_char = SerialPutChar,
|
||||
.get_char = SerialGetChar,
|
||||
};
|
||||
|
@ -311,7 +301,7 @@ static int BoardSerialDevBend(struct SerialHardwareDevice *serial_device, void *
|
|||
struct SerialDriver serial_driver_1;
|
||||
struct SerialHardwareDevice serial_device_1;
|
||||
|
||||
void USART1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void USART1_IRQHandler(void) __attribute__((interrupt()));
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
GET_INT_SP();
|
||||
|
|
Loading…
Reference in New Issue