目录
该文章计划春节假期完成;
修改记录
2021-04-03
添加BOS具体移植过程记录;
内容:基于沁恒官方库,移植babyOS;
更新:
1:移植已经完成,还没来得及更新;其实移植很简单,就是SYStick 中断中加入bHalIncSysTick();然后HAL 接口完善一下;
工程目录建立
代码修改
main.c
/*******************************************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Return : None
*******************************************************************************/
int main(void)
{
bInit();
while(1)
{
bExec();
}
}
ch32f10x_it.c
/*******************************************************************************
* Function Name : SysTick_Handler
* Description : This function handles SysTick Handler.
* Input : None
* Return : None
*******************************************************************************/
void SysTick_Handler(void)
{
static uint8_t outbit = 1;
outbit ^= (1<<0);
bHalGPIO_WritePin(B_HAL_GPIOA, B_HAL_PIN0, outbit);
bHalIncSysTick();
}
b_hal.c
void bHalInit()
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
// SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
// Add code ...gpio init or some other functions
if(SysTick_Config(SystemCoreClock/1000)) //init systick 1ms
{
while(1);
}
USART_Printf_Init(115200);
bHalGPIO_Config(B_HAL_GPIOA, B_HAL_PIN0, B_HAL_GPIO_Out_PP, 0);
}
b_hal_uart.c
/**
* \addtogroup UART_Exported_Functions
* \{
*/
void bHalUartSend(bHalUartNumber_t uart, uint8_t *pbuf, uint16_t len)
{
switch (uart)
{
case B_HAL_UART_1:
// HAL_UART_Transmit(&huart1, pbuf, len, 0xffff);
while(len --)
{
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
USART_SendData(USART1, (u8) (*pbuf++));
}
break;
case B_HAL_UART_2:
break;
case B_HAL_UART_3:
// HAL_UART_Transmit(&huart3, pbuf, len, 0xffff);
break;
case B_HAL_UART_4:
// HAL_UART_Transmit(&huart4, pbuf, len, 0xffff);
break;
case B_HAL_UART_5:
// HAL_UART_Transmit(&huart5, pbuf, len, 0xffff);
break;
case B_HAL_UART_6:
break;
case B_HAL_UART_7:
// HAL_UART_Transmit(&huart7, pbuf, len, 0xffff);
break;
default:
break;
}
}
测试
log打印正常了,下面的flash初始化问题是因为“b_drv_spiflash.c” 中对这部分初始化,没有对应硬件导致;