📄 mw_c28xx_csl.c
字号:
#include "DSP281x_Device.h"
#include "rtwtypes.h"
#include "c2000scitest_2812tgt.h"
#include "c2000scitest_2812tgt_private.h"
volatile int pendingInterrupt = 0;
/* Function: schedulerTimer_ISR() -------------------------------------
*
* Abstract:
* This function services interrupts posted by scheduler timer
*/
interrupt void schedulerTimer_ISR(void)
{
pendingInterrupt = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Enable CPU INT1 - hooked to CPU Timer 0
}
/*-----------------------------------------------------------------------------
* void config_schedulerTimer(void)
*
* Abstract:
* This function configures scheduler timer
*/
void config_schedulerTimer(void)
{
InitCpuTimers();
/* Reassign the PIE vector for TINT0 to point to a specific ISR */
EALLOW;
PieVectTable.TINT0 = &schedulerTimer_ISR;
EDIS;
/* Configure CPU-Timer 0 to interrupt every 0.1 sec. */
/* Parameters: Timer Pointer, CPU Freq in MHz, Period in usec. */
ConfigCpuTimer(&CpuTimer0, 150, 0.1 * 1000000);
StartCpuTimer0();
/* Enable TINT0 in the PIE: Group 1 interrupt 7 */
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
}
void disableWatchdog(void)
{
int *WatchdogWDCR = (void *) 0x7029;
asm(" EALLOW ");
*WatchdogWDCR = 0x0068;
asm(" EDIS ");
}
void init_SCI(uint32_T BaudRate,uint16_T CharacterLengthBits,uint16_T
ClockSpeed,uint16_T EnableLoopBack,uint16_T EnableParity,uint16_T
NumberOfStopBits,uint16_T ParityMode,uint16_T SuspensionMode,uint16_T
UARTInterface)
{ /* initialize SCI & FIFO registers */
EALLOW;
SciaRegs.SCICCR.bit.STOPBITS = NumberOfStopBits-1; // Bit7, Number of Stop Bits
SciaRegs.SCICCR.bit.PARITY = ParityMode-1; // Bit6, Even or Odd Parity
SciaRegs.SCICCR.bit.PARITYENA = EnableParity; // Bit5, Parity enable
SciaRegs.SCICCR.bit.LOOPBKENA = EnableLoopBack; // Bit4, Loop Back enable
SciaRegs.SCICCR.bit.ADDRIDLE_MODE = 0; // Bit3, ADDR/IDLE Mode control
SciaRegs.SCICCR.bit.SCICHAR = CharacterLengthBits-1; // Bit0~2, Character length control
SciaRegs.SCICTL1.bit.SWRESET = 1; // Bit5, Software reset
SciaRegs.SCICTL1.bit.TXENA = 1; // SCI transmitter enable
SciaRegs.SCICTL1.bit.RXENA = 1; // SCI receiver enable
SciaRegs.SCIHBAUD = ((ClockSpeed*1000000/4)/(BaudRate*8) - 1) >> 8;// Baud rate (high) register, BRR = LSPCLK/(SCI Asynchronous Baud)*8 - 1
SciaRegs.SCILBAUD = ((ClockSpeed*1000000/4)/(BaudRate*8) - 1); // Baud rate (low) register, LSPCLK =150/2/2=37.5Mhz
//Free run, continue SCI operation regardless of suspend
SciaRegs.SCIPRI.bit.FREE = 1; // Free emulation mode control, bit 3 =1
SciaRegs.SCIPRI.bit.SOFT =1; // Interrupt priority select, bit 4 =x
SciaRegs.SCIFFCT.bit.ABDCLR = 0;
SciaRegs.SCIFFCT.bit.CDC = 0;
EDIS;
}
/* Function: enable_interrupts -------------------------------
*
* Abstract:
* Enable required c2800 DSP interrupts
*/
void enable_interrupts()
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Enable CPU INT1 - hooked to CPU Timer 0
IER |= M_INT1; // Enable Global INT1 (CPU Interrupt 1)
EINT; // Enable Global interrupt INTM
}
/* Function: disable_interrupts -------------------------------
*
* Abstract:
* Disable required c2800 DSP interrupts
*/
void disable_interrupts()
{
IER &= M_INT1; // Disable Global INT1 (CPU Interrupt 1)
DINT; // Disable Global interrupt INTM
}
/* Function: init_board() -------------------------------------
*
* Abstract:
* This function initializes the board
*/
void init_board ()
{
InitSysCtrl();
/* Disable and clear all CPU interrupts */
DINT;
IER = 0x0000;
IFR = 0x0000;
InitPieCtrl();
InitPieVectTable();
/* initial SPI function.... */
/* initial SCI function.... */
/* Initialize SPIModule with following parameters:
* BaudRate : 9600
* CharacterLengthBits: 8
* ClockSpeed : 150
* EnableLoopBack : 0 , off
* EnableParity : 0 ,off
* NumberOfStopBits : 1
* ParityMode : 2 ,Even
* SuspensionMode : 3 ,Free_run
* UARTInterface : 2 ,To/From_host_block */
init_SCI (9600,8,150,0,0,1,2,3,2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -