⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 board.c

📁 RT-Thread是发展中的下一代微内核嵌入式实时操作系统
💻 C
字号:
/* * File      : board.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2006, RT-Thread Develop Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://openlab.rt-thread.com/license/LICENSE * * Change Logs: * Date           Author       Notes * 2006-08-23     Bernard      first implementation */#include <rtthread.h>#include <rthw.h>#include <AT91SAM7S.h>static void rt_hw_board_led_init();
/** * @addtogroup icdevs64 *//*@{*/#define TCK  1000                           /* Timer Clock  */
#define PIV  ((MCK/TCK/16)-1)               /* Periodic Interval Value */
/**  * This is the timer interrupt service routine. * */void rt_hw_timer_handler(int vector){	if (AT91C_PITC_PISR & 0x01)	{		/* increase a tick */		rt_tick_increase();				/* ack interrupt */		AT91C_AIC_EOICR = AT91C_PITC_PIVR;	}	else 	{		/* end of interrupt */		AT91C_AIC_EOICR = 0;	}}						/* PIO   Flash    PA    PB   PIN */ #define LED1 (1 << 0)	/* PA0 / PGMEN0 & PWM0 TIOA0  48 */ #define LED2 (1 << 1)	/* PA1 / PGMEN1 & PWM1 TIOB0  47 */ #define LED3 (1 << 2)	/* PA2          & PWM2 SCK0   44 */ #define LED4 (1 << 8)	/* PA3          & TWD  NPCS3  43 */ #define LED_MASK		(LED1|LED2|LED3|LED4)/**  * This function will init led on the board */static void rt_hw_board_led_init(){	/* enable the clock of the PIO */	AT91C_PMC_PCER = 1 << 2;	/* configure PIO as output for led */	AT91C_PIO_PER = LED_MASK;	AT91C_PIO_OER = LED_MASK;}/**  * This function will take the led on board on. * * @param n the number nth led */void rt_hw_board_led_on(int n){
	if (n == 4) n = 8;	AT91C_PIO_CODR = 1 << n;}/**  * This function will take the led on board off. * * @param n the number nth led */void rt_hw_board_led_off(int n){
	if (n == 4) n = 8;	AT91C_PIO_SODR = 1 << n;}/** * This function will init icdev AT91SAM7S board */void rt_hw_board_init(){	/* init led */	rt_hw_board_led_init();		/* install timer handler */	rt_hw_interrupt_install(AT91C_ID_SYS, rt_hw_timer_handler, RT_NULL);	/* init PITC */	AT91C_PITC_PIMR = (1 << 25) | (1 << 24) | PIV;	rt_hw_interrupt_umask(AT91C_ID_SYS);}/*@}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -