fix the project
This commit is contained in:
parent
abcac46fcf
commit
864d1dd703
|
@ -11,27 +11,22 @@
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <rtdevice.h>
|
#include <rtdevice.h>
|
||||||
#define DK_BOARD_LED_1 13
|
|
||||||
#define DK_BOARD_LED_2 14
|
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
const gpio_cfg_t led_pin[] = {
|
const gpio_cfg_t led_pin[] =
|
||||||
|
{
|
||||||
{PORT_0, PIN_13, GPIO_FUNC_OUT, GPIO_PAD_NONE},
|
{PORT_0, PIN_13, GPIO_FUNC_OUT, GPIO_PAD_NONE},
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int count = 1;
|
int count = 1;
|
||||||
GPIO_Config(&led_pin[0]);
|
GPIO_Config(&led_pin[0]);
|
||||||
//rt_pin_mode(DK_BOARD_LED_1, PIN_MODE_OUTPUT);
|
|
||||||
GPIO_OutSet(&led_pin[0]);
|
GPIO_OutSet(&led_pin[0]);
|
||||||
while (count++)
|
while (count++)
|
||||||
{
|
{
|
||||||
//rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
|
||||||
rt_thread_mdelay(500);
|
rt_thread_mdelay(500);
|
||||||
GPIO_OutToggle(&led_pin[0]);
|
GPIO_OutToggle(&led_pin[0]);
|
||||||
//rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
|
|
||||||
//rt_thread_mdelay(500);
|
|
||||||
}
|
}
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,6 @@
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "rtdevice.h"
|
#include "rtdevice.h"
|
||||||
|
|
||||||
#define BUFF_SIZE 10
|
|
||||||
uint8_t rxdata[BUFF_SIZE]={0};
|
|
||||||
|
|
||||||
|
|
||||||
#define UART0_CONFIG \
|
#define UART0_CONFIG \
|
||||||
{ \
|
{ \
|
||||||
.name = "uart0", \
|
.name = "uart0", \
|
||||||
|
@ -89,7 +85,7 @@ void UART1_IRQHandler(void)
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
|
|
||||||
rt_hw_serial_isr(&(uart_obj[UART1_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
|
rt_hw_serial_isr(&(uart_obj[UART1_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
|
||||||
/* leave interrupt */
|
|
||||||
uint32_t intst = 0;
|
uint32_t intst = 0;
|
||||||
intst = MXC_UART1->int_fl;
|
intst = MXC_UART1->int_fl;
|
||||||
MXC_UART1->int_fl = intst;
|
MXC_UART1->int_fl = intst;
|
||||||
|
@ -101,12 +97,12 @@ void UART1_IRQHandler(void)
|
||||||
#ifdef BSP_USING_UART0
|
#ifdef BSP_USING_UART0
|
||||||
void UART0_IRQHandler(void)
|
void UART0_IRQHandler(void)
|
||||||
{
|
{
|
||||||
//UART_Handler(MXC_UART0);
|
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
|
|
||||||
rt_hw_serial_isr(&(uart_obj[UART0_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
|
rt_hw_serial_isr(&(uart_obj[UART0_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
|
||||||
/* leave interrupt */
|
/* clear flags */
|
||||||
|
|
||||||
uint32_t intst = 0;
|
uint32_t intst = 0;
|
||||||
intst = MXC_UART0->int_fl;
|
intst = MXC_UART0->int_fl;
|
||||||
MXC_UART0->int_fl = intst;
|
MXC_UART0->int_fl = intst;
|
||||||
|
@ -119,11 +115,12 @@ void UART0_IRQHandler(void)
|
||||||
|
|
||||||
static rt_err_t mcu_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
static rt_err_t mcu_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
||||||
{
|
{
|
||||||
int error, i;
|
int error;
|
||||||
struct mcu_uart *uart;
|
struct mcu_uart *uart;
|
||||||
RT_ASSERT(serial != RT_NULL);
|
RT_ASSERT(serial != RT_NULL);
|
||||||
RT_ASSERT(cfg != RT_NULL);
|
RT_ASSERT(cfg != RT_NULL);
|
||||||
const sys_cfg_uart_t sys_uart_cfg = {
|
const sys_cfg_uart_t sys_uart_cfg =
|
||||||
|
{
|
||||||
MAP_A,
|
MAP_A,
|
||||||
UART_FLOW_DISABLE,
|
UART_FLOW_DISABLE,
|
||||||
};
|
};
|
||||||
|
@ -137,9 +134,11 @@ static rt_err_t mcu_configure(struct rt_serial_device *serial, struct serial_con
|
||||||
mcu_cfg.flow = UART_FLOW_CTRL_EN;
|
mcu_cfg.flow = UART_FLOW_CTRL_EN;
|
||||||
mcu_cfg.pol = UART_FLOW_POL_EN;
|
mcu_cfg.pol = UART_FLOW_POL_EN;
|
||||||
|
|
||||||
error= UART_Init(uart->handle, &mcu_cfg, &sys_uart_cfg);
|
error = UART_Init(uart->handle, &mcu_cfg, &sys_uart_cfg);
|
||||||
|
if (error != E_NO_ERROR) {
|
||||||
|
rt_kprintf("Error initializing UART %d\n", error);
|
||||||
|
while(1) {}
|
||||||
|
}
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +154,6 @@ static rt_err_t mcu_control(struct rt_serial_device *serial, int cmd, void *arg)
|
||||||
/* disable interrupt */
|
/* disable interrupt */
|
||||||
case RT_DEVICE_CTRL_CLR_INT:
|
case RT_DEVICE_CTRL_CLR_INT:
|
||||||
/* disable rx irq */
|
/* disable rx irq */
|
||||||
// NVIC_DisableIRQ(uart->config->irq_type);
|
|
||||||
NVIC_ClearPendingIRQ(uart->config->irq_type);
|
NVIC_ClearPendingIRQ(uart->config->irq_type);
|
||||||
NVIC_DisableIRQ(uart->config->irq_type);
|
NVIC_DisableIRQ(uart->config->irq_type);
|
||||||
/* disable interrupt */
|
/* disable interrupt */
|
||||||
|
@ -168,27 +166,19 @@ static rt_err_t mcu_control(struct rt_serial_device *serial, int cmd, void *arg)
|
||||||
NVIC_EnableIRQ(uart->config->irq_type);
|
NVIC_EnableIRQ(uart->config->irq_type);
|
||||||
/* enable interrupt */
|
/* enable interrupt */
|
||||||
uart->handle->ctrl |= 0x05 << MXC_F_UART_CTRL_RX_TO_POS;
|
uart->handle->ctrl |= 0x05 << MXC_F_UART_CTRL_RX_TO_POS;
|
||||||
uart->handle->int_en |= MXC_F_UART_INT_EN_RX_FIFO_THRESH | MXC_F_UART_INT_EN_RX_TIMEOUT;
|
uart->handle->int_en |= MXC_F_UART_INT_EN_RX_FIFO_THRESH | \
|
||||||
#define UART_ER_IE (MXC_F_UART_INT_EN_RX_FRAME_ERROR | \
|
MXC_F_UART_INT_EN_RX_TIMEOUT;
|
||||||
MXC_F_UART_INT_EN_RX_PARITY_ERROR | \
|
|
||||||
MXC_F_UART_INT_EN_RX_OVERRUN )
|
|
||||||
uart->handle->int_en |= UART_ER_IE;
|
|
||||||
|
|
||||||
uart->handle->thresh_ctrl=MXC_UART_FIFO_DEPTH<<
|
uart->handle->int_en |= MXC_F_UART_INT_EN_RX_FRAME_ERROR | \
|
||||||
|
MXC_F_UART_INT_EN_RX_PARITY_ERROR | \
|
||||||
|
MXC_F_UART_INT_EN_RX_OVERRUN ;
|
||||||
|
|
||||||
|
uart->handle->thresh_ctrl = MXC_UART_FIFO_DEPTH <<
|
||||||
MXC_F_UART_THRESH_CTRL_RX_FIFO_THRESH_POS;
|
MXC_F_UART_THRESH_CTRL_RX_FIFO_THRESH_POS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef RT_SERIAL_USING_DMA
|
|
||||||
case RT_DEVICE_CTRL_CONFIG:
|
|
||||||
stm32_dma_config(serial, ctrl_arg);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case RT_DEVICE_CTRL_CLOSE:
|
case RT_DEVICE_CTRL_CLOSE:
|
||||||
// if (HAL_UART_DeInit(&(uart->handle)) != HAL_OK )
|
UART_Shutdown(uart->handle);
|
||||||
// {
|
|
||||||
// RT_ASSERT(0)
|
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -214,7 +204,7 @@ static int mcu_getc(struct rt_serial_device *serial)
|
||||||
|
|
||||||
ch = -1;
|
ch = -1;
|
||||||
|
|
||||||
if(UART_NumReadAvail(uart->handle))
|
if (UART_NumReadAvail(uart->handle))
|
||||||
{
|
{
|
||||||
ch = UART_ReadByte(uart->handle);
|
ch = UART_ReadByte(uart->handle);
|
||||||
}
|
}
|
||||||
|
@ -222,10 +212,6 @@ static int mcu_getc(struct rt_serial_device *serial)
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const struct rt_uart_ops mcu_uart_ops =
|
static const struct rt_uart_ops mcu_uart_ops =
|
||||||
{
|
{
|
||||||
.configure = mcu_configure,
|
.configure = mcu_configure,
|
||||||
|
|
|
@ -5,11 +5,10 @@
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2018.10.30 SummerGift first version
|
* 2021-02-08 Supperthomas first version
|
||||||
* 2019.03.05 whj4674672 add stm32h7
|
|
||||||
* 2020-10-14 Dozingfiretruck Porting for stm32wbxx
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __DRV_USART_H__
|
#ifndef __DRV_USART_H__
|
||||||
#define __DRV_USART_H__
|
#define __DRV_USART_H__
|
||||||
|
|
||||||
|
|
|
@ -32,34 +32,24 @@ void SysTick_Handler(void)
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysTick_Configuration(void)
|
void rt_hw_systick_init(void)
|
||||||
{
|
{
|
||||||
uint32_t error;
|
uint32_t error;
|
||||||
error = SYS_SysTick_Config(SYS_SysTick_GetFreq()/RT_TICK_PER_SECOND, 1, MXC_TMR0);
|
error = SYS_SysTick_Config(SYS_SysTick_GetFreq() / RT_TICK_PER_SECOND, 1, MXC_TMR0);
|
||||||
|
|
||||||
if (error != E_NO_ERROR) {
|
if (error != E_NO_ERROR)
|
||||||
|
{
|
||||||
printf("ERROR: Ticks is not valid");
|
printf("ERROR: Ticks is not valid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mxc_uart_regs_t *ConsoleUART = MXC_UART_GET_UART(1);
|
|
||||||
|
|
||||||
const sys_cfg_uart_t console_uart_sys_cfg = {
|
|
||||||
MAP_A,
|
|
||||||
UART_FLOW_DISABLE,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void rt_hw_board_init(void)
|
void rt_hw_board_init(void)
|
||||||
{
|
{
|
||||||
// rt_hw_interrupt_enable(0);
|
|
||||||
// sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
|
|
||||||
/* Activate deep sleep mode */
|
|
||||||
|
|
||||||
SysTick_Configuration();
|
rt_hw_systick_init();
|
||||||
|
|
||||||
#if defined(RT_USING_HEAP)
|
#if defined(RT_USING_HEAP)
|
||||||
rt_system_heap_init((void *)(0x20000000+16*1024), (void *)(0x20000000+64*1024));
|
rt_system_heap_init((void *)(HEAP_BEGIN), (void *)(HEAP_END));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RT_USING_SERIAL
|
#ifdef RT_USING_SERIAL
|
||||||
|
@ -73,8 +63,5 @@ void rt_hw_board_init(void)
|
||||||
#ifdef RT_USING_COMPONENTS_INIT
|
#ifdef RT_USING_COMPONENTS_INIT
|
||||||
rt_components_board_init();
|
rt_components_board_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,13 @@
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <rthw.h>
|
#include <rthw.h>
|
||||||
|
|
||||||
#define MCU_FLASH_SIZE MCU_FLASH_SIZE_KB*1024
|
#define MCU_FLASH_START_ADRESS ((uint32_t)0x0)
|
||||||
#define MCU_FLASH_END_ADDRESS ((uint32_t)(MCU_FLASH_START_ADDRESS + MCU_FLASH_SIZE))
|
#define MCU_FLASH_SIZE_KB (256)
|
||||||
#define MCU_SRAM_SIZE MCU_SRAM_SIZE_KB*1024
|
#define MCU_FLASH_END_ADDRESS ((uint32_t)(MCU_FLASH_START_ADRESS + MCU_FLASH_SIZE*1024))
|
||||||
#define MCU_SRAM_END_ADDRESS (MCU_SRAM_START_ADDRESS + MCU_SRAM_SIZE)
|
|
||||||
|
#define MCU_SRAM_SIZE_KB (96)
|
||||||
|
#define MCU_SRAM_START (0x20000000)
|
||||||
|
#define MCU_SRAM_END (MCU_SRAM_START + MCU_SRAM_SIZE_KB * 1024)
|
||||||
|
|
||||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||||
|
@ -20,8 +23,7 @@ extern int __bss_end__;
|
||||||
#define HEAP_BEGIN ((void *)&__bss_end__)
|
#define HEAP_BEGIN ((void *)&__bss_end__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HEAP_SIZE 16*1024
|
#define HEAP_END MCU_SRAM_END
|
||||||
#define HEAP_END (HEAP_BEGIN + HEAP_SIZE)
|
|
||||||
|
|
||||||
void rt_hw_board_init(void);
|
void rt_hw_board_init(void);
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,38 @@
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression></Expression>
|
<Expression></Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>5</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>209</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>0</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>0</BreakIfRCount>
|
||||||
|
<Filename>.\applications\drv_uart.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression></Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>6</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>220</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>0</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>0</BreakIfRCount>
|
||||||
|
<Filename>.\applications\drv_uart.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression></Expression>
|
||||||
|
</Bp>
|
||||||
</Breakpoint>
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
|
@ -562,7 +594,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>CPU</GroupName>
|
<GroupName>CPU</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
|
Loading…
Reference in New Issue