📄 c6201_hw.c
字号:
/*****************************************************************************
*
* component :
*
* module name : c6201_hw.c
* date :
*
* subcomponent:
*
******************************************************************************
*
* function :
* description :
*
******************************************************************************
*
*
* dependencies:
*
* uC/OS-II The Realtime KERNEL by Jean J. Labrosse
*
* author : Kenneth Blake - Oberon Data och Elektronik AB
* ken@oberon.se www.oberon.se
* history :
*
*
******************************************************************************/
#include <intr.h>
#include "includes.h"
#include <timer.h>
void c6201_Save(void) ; /* C6201 runtime saving of task registers */
void c6201_Restor(void) ; /* C6201 runtime popping of task registers */
void interrupt
TimerZeroTick(void) /* Interrupt 14, Debug interrupt Aid */
{
}
/******************************************************************************
*
* function : TimerOneTick(void )
* description : Timer 1 tick interrupt handler
*
* Ticks every millisecond
*
* dependencies: Setup in the interrupt vector : c6inthnd.asm
* os_cpu_a.asm
*
* Input : None
* Output : None
* history :
* return value :
* Cost :
*
******************************************************************************/
/*------------------------------**
** Timer one interrupt handler **
**------------------------------*/
/* do not declare this with the
ordinary interrupt keyword
or #pragma interrupt () ; */
void
TimerOneTick(void) /* Interrupt 15, System Timer One millisecond */
{
c6201_Save() ; /* C6201 runtime saving of task registers */
OSIntEnter() ;
OSMboxPost( MailBox->ForTheClockInterrupt, (void *)1);
OSIntExit() ;
/* CSR = CSR & (unsigned int)-2;*/
c6201_Restor() ; /* C6201 runtime popping of task registers */
}
/******************************************************************************
*
* function : DMAChannel_0_Interrupt (void )
* DMAChannel_1_Interrupt (void )
* DMAChannel_3_Interrupt (void )
* DMAChannel_4_Interrupt (void )
*
* description : DMA controller interrupt's handlers
*
* Acts on an interrupt when the DMA channel issues an interrupt
*
* dependencies: Setup in the interrupt vector : c6inthnd.asm
* os_cpu_a.asm
*
* Input : None
* Output : None
* history :
* return value :
* Cost :
*
******************************************************************************/
void interrupt
DMAChannel_0_Interrupt (void) /* Interrupt 8 */
{
}
void interrupt
DMAChannel_1_Interrupt (void) /* Interrupt 9 */
{
}
void interrupt
DMAChannel_2_Interrupt (void) /* Interrupt 11 */
{
}
void interrupt
DMAChannel_3_Interrupt (void) /* Interrupt 12 */
{
}
/******************************************************************************
*
* function : Illegal_Interrupt_Handler (void)
* description : Illegal Interrupt handler
*
* A Pure autonomous interrupt handler that has nothing to do
* with the KERNEL.
*
* Called whenever an interrupt occures that is not set ok or an error situation
* has occured. This interrupt handler should never execute.
* But is here for debugging purposes
*
* dependencies: Setup in the interrupt vector : vectors.asm
* Do not use a C call in the routine if it can be avoided
* otherwise the C compiler generates a big push and pop allocation frame
* on the stack (takes time)
* Input : None
* Output : None
* history :
* return value :
* Cost :
*
******************************************************************************/
interrupt void
Illegal_Interrupt_Handler(void)
{
/* Illegal interrupts shall never be called */
}
MSGS
C6201_Set_Up_TIMER_Tick_In_TenthsOfMicroseconds( int TenthsOfMicroseconds )
{
typedef struct
{
unsigned int
Control,
Period,
Counter;
}
TIMER_REG ;
INT32U clock_cycles ;
volatile TIMER_REG *timer_reg ;
timer_reg = (volatile TIMER_REG *)TIMER1_CTRL_ADDR;
clock_cycles = (float)TenthsOfMicroseconds * 1e-7 * CLOCK_PER_SEC ;
timer_reg->Control = 0; /* Hold it */
timer_reg->Control = 0;
timer_reg->Period = clock_cycles / 2 ; /* SET DELAY TIME */
/*-----------------**
** 9 CLKSRC = 1 CPU clock / 4 **
** 8 C/P = 1 Clock mode **
** 7 /HLD = 1 Allowed to count **
** 6 GO = 1 Here we go **
**-----------------*/
timer_reg->Control = (1<<6) +(1<<7) + (1<<8) + (1<<9) ;
timer_reg->Control = (1<<6) +(1<<7) + (1<<8) + (1<<9);
return (NO_ERROR);
}
MSGS
C6201_Set_Up_TIMER_0_In_TenthsOfMicroseconds( int TenthsOfMicroseconds )
{
typedef struct
{
unsigned int
Control,
Period,
Counter;
}
TIMER_REG ;
INT32U clock_cycles ;
volatile TIMER_REG *timer_reg ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -