未验证 提交 db16ba50 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #4499 from mysterywolf/mb9bf506r

[mb9bf506r]manual & auto formatted
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
......@@ -33,35 +29,35 @@
void rt_init_thread_entry(void *parameter)
{
/* LED Initialization */
rt_hw_led_init();
/* LED Initialization */
rt_hw_led_init();
#ifdef RT_USING_COMPONENTS_INIT
/* initialization RT-Thread Components */
rt_components_init();
/* initialization RT-Thread Components */
rt_components_init();
#endif
/* Filesystem Initialization */
/* Filesystem Initialization */
#ifdef RT_USING_DFS
/* mount nand fat partition 1 as root directory */
if (dfs_mount("nand", "/", "elm", 0, 0) == 0)
rt_kprintf("File System initialized!\n");
else
rt_kprintf("File System init failed!\n");
/* mount nand fat partition 1 as root directory */
if (dfs_mount("nand", "/", "elm", 0, 0) == 0)
rt_kprintf("File System initialized!\n");
else
rt_kprintf("File System init failed!\n");
#endif
}
int rt_application_init(void)
{
rt_thread_t tid;
rt_thread_t tid;
tid = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, RT_THREAD_PRIORITY_MAX/3, 20);
if (tid != RT_NULL)
rt_thread_startup(tid);
tid = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, RT_THREAD_PRIORITY_MAX/3, 20);
if (tid != RT_NULL)
rt_thread_startup(tid);
return 0;
return 0;
}
/*@}*/
/*
* File : startup.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
......@@ -38,60 +34,60 @@ extern int __bss_end;
*/
void rtthread_startup(void)
{
/* initialize board */
rt_hw_board_init();
/* initialize board */
rt_hw_board_init();
/* show version */
rt_show_version();
/* show version */
rt_show_version();
#ifdef RT_USING_HEAP
#ifdef __CC_ARM
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
#elif __ICCARM__
rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
#else
/* init memory system */
rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
#endif
#ifdef __CC_ARM
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
#elif __ICCARM__
rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
#else
/* init memory system */
rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
#endif
#endif
/* init scheduler system */
rt_system_scheduler_init();
/* init scheduler system */
rt_system_scheduler_init();
#ifdef RT_USING_DEVICE
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_UFFS)
rt_hw_nand_init();
rt_hw_nand_init();
#endif
#endif
/* initialize application */
rt_application_init();
/* initialize application */
rt_application_init();
/* initialize timer */
rt_system_timer_init();
/* initialize timer thread */
rt_system_timer_thread_init();
/* initialize timer thread */
rt_system_timer_thread_init();
/* initialize idle thread */
rt_thread_idle_init();
/* initialize idle thread */
rt_thread_idle_init();
/* start scheduler */
rt_system_scheduler_start();
/* start scheduler */
rt_system_scheduler_start();
/* never reach here */
return ;
/* never reach here */
return ;
}
int main(void)
{
/* disable interrupt first */
rt_hw_interrupt_disable();
/* disable interrupt first */
rt_hw_interrupt_disable();
/* startup RT-Thread RTOS */
rtthread_startup();
/* startup RT-Thread RTOS */
rtthread_startup();
return 0;
return 0;
}
/*@}*/
/*
* File : board.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012 RT-Thread Develop Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
......@@ -32,13 +28,13 @@
*/
void SysTick_Handler(void)
{
/* enter interrupt */
rt_interrupt_enter();
/* enter interrupt */
rt_interrupt_enter();
rt_tick_increase();
rt_tick_increase();
/* leave interrupt */
rt_interrupt_leave();
/* leave interrupt */
rt_interrupt_leave();
}
/**
......@@ -46,16 +42,16 @@ void SysTick_Handler(void)
*/
void rt_hw_board_init(void)
{
/* init systick */
SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
/* initialize UART device */
rt_hw_serial_init();
/* set console as UART device */
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
/* initialize nand flash device */
rt_hw_nand_init();
/* init systick */
SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
/* initialize UART device */
rt_hw_serial_init();
/* set console as UART device */
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
/* initialize nand flash device */
rt_hw_nand_init();
}
/*@}*/
/*
* File : board.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
......
此差异已折叠。
/*
* File : fm3_uart.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
......@@ -55,7 +51,7 @@
#define ESCR_DATABITS_7 0x03U
#define ESCR_DATABITS_9 0x04U
#define FIFO_SIZE 16
#define FIFO_SIZE 16
/*
* Enable/DISABLE Interrupt Controller
......@@ -66,19 +62,19 @@
struct uart03_device
{
FM3_MFS03_UART_TypeDef *uart_regs;
/* irq number */
IRQn_Type rx_irq;
IRQn_Type tx_irq;
FM3_MFS03_UART_TypeDef *uart_regs;
/* irq number */
IRQn_Type rx_irq;
IRQn_Type tx_irq;
};
struct uart47_device
{
FM3_MFS47_UART_TypeDef *uart_regs;
/* irq number */
IRQn_Type rx_irq;
IRQn_Type tx_irq;
rt_uint8_t fifo_size;
FM3_MFS47_UART_TypeDef *uart_regs;
/* irq number */
IRQn_Type rx_irq;
IRQn_Type tx_irq;
rt_uint8_t fifo_size;
};
void rt_hw_serial_init(void);
......
/*
* File : led.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, RT-Thread Develop Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2011-03-03 lgnq
*/
#include <rtthread.h>
#include <rthw.h>
......@@ -20,8 +16,8 @@
void rt_hw_led_on(rt_uint8_t num)
{
RT_ASSERT(num < LEDS_MAX_NUMBER);
RT_ASSERT(num < LEDS_MAX_NUMBER);
switch (num)
{
case 1:
......@@ -31,16 +27,16 @@ void rt_hw_led_on(rt_uint8_t num)
USER_LED_PDOR &= ~USER_LED2;
break;
case 3:
USER_LED_PDOR &= ~USER_LED3;
USER_LED_PDOR &= ~USER_LED3;
break;
default:
break;
}
}
}
void rt_hw_led_off(rt_uint8_t num)
{
RT_ASSERT(num < LEDS_MAX_NUMBER);
RT_ASSERT(num < LEDS_MAX_NUMBER);
switch (num)
{
......@@ -51,17 +47,17 @@ void rt_hw_led_off(rt_uint8_t num)
USER_LED_PDOR |= USER_LED2;
break;
case 3:
USER_LED_PDOR |= USER_LED3;
USER_LED_PDOR |= USER_LED3;
break;
default:
break;
}
}
}
void rt_hw_led_toggle(rt_uint8_t num)
{
RT_ASSERT(num < LEDS_MAX_NUMBER);
RT_ASSERT(num < LEDS_MAX_NUMBER);
switch (num)
{
case 1:
......@@ -80,11 +76,11 @@ void rt_hw_led_toggle(rt_uint8_t num)
if (USER_LED_PDOR&USER_LED3)
USER_LED_PDOR &= ~USER_LED3;
else
USER_LED_PDOR |= USER_LED3;
USER_LED_PDOR |= USER_LED3;
break;
default:
break;
}
}
}
void led_init(void)
......@@ -102,7 +98,7 @@ void led_init(void)
void pwm_update(rt_uint16_t value)
{
FM3_BT2_PWM->PDUT = value;
FM3_BT2_PWM->PDUT = value;
}
static void led1_thread_entry(void *parameter)
......@@ -130,11 +126,11 @@ void rt_hw_led_init(void)
led_init();
led1_thread = rt_thread_create("led1", led1_thread_entry, RT_NULL, 384, 29, 5);
if (led1_thread != RT_NULL)
if (led1_thread != RT_NULL)
rt_thread_startup(led1_thread);
led2_thread = rt_thread_create("led2", led2_thread_entry, RT_NULL, 384, 30, 5);
if (led2_thread != RT_NULL)
if (led2_thread != RT_NULL)
rt_thread_startup(led2_thread);
}
......
/*
* File : led.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, RT-Thread Develop Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2011-03-03 lgnq
*/
#ifndef __LED_H__
#define __LED_H__
#include "mb9bf506r.h"
#define LEDS_MAX_NUMBER 4
#define LEDS_MAX_NUMBER 4
/* LED */
#define USER_LED1 (1UL<<0x9)
#define USER_LED2 (1UL<<0xa)
#define USER_LED3 (1UL<<0xb)
#define USER_LED_MASK (USER_LED1 | USER_LED2 | USER_LED3)
#define USER_LED_PFR FM3_GPIO->PFR1
#define USER_LED_PCR FM3_GPIO->PCR1
#define USER_LED_PDOR FM3_GPIO->PDOR1
#define USER_LED_DDR FM3_GPIO->DDR1
#define USER_LED_MASK (USER_LED1 | USER_LED2 | USER_LED3)
#define USER_LED_PFR FM3_GPIO->PFR1
#define USER_LED_PCR FM3_GPIO->PCR1
#define USER_LED_PDOR FM3_GPIO->PDOR1
#define USER_LED_DDR FM3_GPIO->DDR1
#define RT_DEVICE_CTRL_LED_ON 0
#define RT_DEVICE_CTRL_LED_OFF 1
#define RT_DEVICE_CTRL_LED_TOGGLE 2
#define RT_DEVICE_CTRL_LED_ON 0
#define RT_DEVICE_CTRL_LED_OFF 1
#define RT_DEVICE_CTRL_LED_TOGGLE 2
void rt_hw_led_init(void);
void rt_hw_led_on(rt_uint8_t num);
......
此差异已折叠。
/*
* File : nand.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
......@@ -33,7 +29,7 @@
#define NF_ALE_OFFSET 0x00003000
#define NF_ADDR_OFFSET 0x00002000
#define NF_CMD_OFFSET 0x00001000
#define NF_DATA_OFFSET 0x00000000
#define NF_DATA_OFFSET 0x00000000
/* NAND command */
#define NAND_CMD_READ0 0x00
......@@ -47,7 +43,7 @@
#define NAND_CMD_READID1 0x91
#define NAND_CMD_ERASE2 0xd0
#define NAND_CMD_RESET 0xff
#define FLASH_OK 0
#define FLASH_NG 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册