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

📄 hal.h

📁 ucos在NEC平台下的移植
💻 H
📖 第 1 页 / 共 2 页
字号:
#define ENABLE_TM50_INT()          { TMMK50 = 0; }
#define DISABLE_TM50_INT()         { TMMK50 = 1; }
//-------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------
// Timer/Counter 51 interrupts
#define ENABLE_TM51_INT()          { TMMK51 = 0; }
#define DISABLE_TM51_INT()         { TMMK51 = 1; }
//-------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------
// Timer/Counter 01 interrupts
#define ENABLE_TM001_INT()         { TMMK001 = 0; }
#define DISABLE_TM001_INT()        { TMMK001 = 1; }
#define ENABLE_TM011_INT()         { TMMK011 = 0; }
#define DISABLE_TM011_INT()        { TMMK011 = 1; }
//-------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------
// CSIA0 interrupts
#define ENABLE_CSIA0_INT()         { ACSIMK = 0; }
#define DISABLE_CSIA0_INT();       { ACSIMK = 1; }
//-------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------
// External interrupts
#define ENABLE_P1_INT()            { PMK1 = 0; }
#define DISABLE_P1_INT()           { PMK1 = 1; }
#define ENABLE_P2_INT()            { PMK2 = 0; }
#define DISABLE_P2_INT()           { PMK2 = 1; }
#define ENABLE_P3_INT()            { PMK3 = 0; }
#define DISABLE_P3_INT()           { PMK3 = 1; }
#define ENABLE_P4_INT()            { PMK4 = 0; }
#define DISABLE_P4_INT()           { PMK4 = 1; }


/*******************************************************************************************************
 *******************************************************************************************************
 **************************                      TIMER 50                      **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//-------------------------------------------------------------------------------------------------------
// Timer 50 (8 bits)
// Initialize timer 51 for interrupt at regular intervals, controlled by the compare value, and the precaler value
// Initialization
#define TIMER50_INIT(prescaler, compare, control) { TCL50 = prescaler;  CR50  = compare; TMC50 = control; }
// Prescaler
#define TIMER50_SET_PRESCALER(prescaler)         { TCL50 = prescaler; }
// Operations
#define TIMER50_SET_COMPARE_VALUE(value)         { CR50  = value; }
#define TIMER50_START()                          { TCE50 = 1; }
#define TIMER50_STOP()                           { TCE50 = 0; }
#define CLEAR_TIMER50_INT()           { TMIF50 = 0; }///
//-------------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------------

/*******************************************************************************************************
 *******************************************************************************************************
 **************************                      TIMER 0                      **************************
 *******************************************************************************************************
 *******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// Timer 0 (8 bits) ->  78K0/KF2 TM51

// Initialize timer 51 for interrupt at regular intervals, controlled by the compare value, and the precaler value
// Initialization
///#define TIMER51_INIT(prescaler,compare,control)  { TCL51 = prescaler;  CR51=compare, TMC51 = control; }
#define TIMER51_INIT(prescaler,compare,control)  { }

// Prescaler
#define TIMER51_SET_PRESCALER(prescaler)         { TCL51 = prescaler; }
// Operations
///#define TIMER51_START()                          { TCE51 = 1; }
///#define TIMER51_STOP()                           { TCE51 = 0; }
#define TIMER51_START()                          { }
#define TIMER51_STOP()                            { }

// Operations
#define TIMER51_RESET_VALUE()                    { TM51  = 0x00;  }
#define TIMER51_SET_VALUE(value)                 { TM51  = value; }
#define TIMER51_SET_COMPARE_VALUE(value)         { CR51  = value; }

///#define ENABLE_TIMER51_INT()                     { TMMK51 = 0; }
///#define DISABLE_TIMER51_INT()                    { TMMK51 = 1; }
///#define CLEAR_TIMER51_INT()           { TMIF51 = 0; }///
#define ENABLE_TIMER51_INT()                     { }
#define DISABLE_TIMER51_INT()                    { }
#define CLEAR_TIMER51_INT()           { }///

//-------------------------------------------------------------------------------------------------------



/*******************************************************************************************************
 *******************************************************************************************************
 **************************                      TIMER 1                      **************************
 *******************************************************************************************************
 *******************************************************************************************************/


//-------------------------------------------------------------------------------------------------------
// Timer 1 (16 bits) -> 78K0/KF2 TM01

// Initialize timer 1 for interrupt at regular intervals, controlled by the compare A value, and the
// precaler value
///#define TIMER1_INIT(capcom,prescaler,config)            {CRC01=capcom; PRM01=prescaler; TMC01=config;}
#define TIMER1_INIT(capcom,prescaler,config)            {}


// Options for TIMER1_INIT
// #define TIMER1_CAPTURE_ON_POSEDGE       0x6
// #define TIMER1_CAPTURE_ON_NEGEDGE       0

// Start/stop
///#define TIMER1_START(prescaler)         { TMC01 = 0x04; PRM01= prescaler; }
///#define TIMER1_STOP()                   { TMC01 = 0x00; }
///#define TIMER1_START()         {TMC01 = 0x04; }
///#define TIMER1_STOP()           {TMC01 = 0x00; }
#define TIMER1_START()         {}
#define TIMER1_STOP()           {}


// Prescaler definitions to be used with TIMER1_START(...)

#define TIMER1_CLK                   (PRM01 & 0xF0)        /* Total period = Clock freq      */
#define TIMER1_CLK_DIV16            ((PRM01 & 0xF0)| 0x01) /* Total period = Clock freq / 16 */
#define TIMER1_CLK_DIV64            ((PRM01 & 0xF0)| 0x02) /* Total period = Clock freq / 64 */

#define TIMER1_CLK_T1_NEGEDGE       ((PRM01 & 0x00)| 0x02) /* TI001 pin valid edge           */
#define TIMER1_CLK_T1_POSEDGE       ((PRM01 & 0x00)| 0x42) /* TI001 pin valid edge           */

// Compare value modification
#define TIMER1_SET_COMPA_VALUE(value)   { CR001 = value; }
#define TIMER1_SET_COMPB_VALUE(value)   { CR011 = value; }
//#define TIMER1_SET_COMPC_VALUE(value)  not available in 78K0/KF2

//-------------------------------------------------------------------------------------------------------
// Compare match interrupt T001
#define ENABLE_T1_COMPC_INT()       { TMMK011 = 0; }
#define DISABLE_T1_COMPC_INT()      { TMMK011 = 1; }
#define CLEAR_T1_COMPC_INT()        { TMIF011 = 0; }

// Capture interrupt T011
#define ENABLE_T1_CAPTURE_INT()      { TMMK001 = 0; }
#define DISABLE_T1_CAPTURE_INT()     { TMMK001 = 1; }
#define CLEAR_T1_CAPTURE_INT()       { TMIF001 = 0; }


/*******************************************************************************************************
 *******************************************************************************************************
 **************************                      TIMER 3                      **************************
 *******************************************************************************************************
 *******************************************************************************************************/


//-------------------------------------------------------------------------------------------------------
// Timer 1 (16 bits) -> 78K0/KF2 TM01

// Initialize timer 1 for interrupt at regular intervals, controlled by the compare A value, and the
// precaler value
#define TIMER3_INIT(capcom,prescaler,config)            {CRC00=capcom; PRM00=prescaler; TMC00=config;}
///#define TIMER3_INIT(capcom,prescaler,config)          {}


// Options for TIMER1_INIT
// #define TIMER1_CAPTURE_ON_POSEDGE       0x6
// #define TIMER1_CAPTURE_ON_NEGEDGE       0

// Start/stop
///#define TIMER3_START(prescaler)         { TMC00 = 0x0C; PRM00= prescaler; }///!!!
#define TIMER3_START()         { TMC00 = 0x0C; }///!!!
#define TIMER3_STOP()                   { TMC00 = 0x00; }

// Prescaler definitions to be used with TIMER1_START(...)

#define TIMER3_CLK                   (PRM00 & 0xF0)        /* Total period = Clock freq      */
#define TIMER3_CLK_DIV16            ((PRM00 & 0xF0)| 0x01) /* Total period = Clock freq / 16 */
#define TIMER3_CLK_DIV64            ((PRM00 & 0xF0)| 0x02) /* Total period = Clock freq / 64 */

#define TIMER3_CLK_T1_NEGEDGE       ((PRM00 & 0x00)| 0x02) /* TI001 pin valid edge           */
#define TIMER3_CLK_T1_POSEDGE       ((PRM00 & 0x00)| 0x42) /* TI001 pin valid edge           */

// Compare value modification
#define TIMER3_SET_COMPA_VALUE(value)   { CR000 = value; }
#define TIMER3_SET_COMPB_VALUE(value)   { CR010 = value; }
//#define TIMER1_SET_COMPC_VALUE(value)  not available in 78K0/KF2

//-------------------------------------------------------------------------------------------------------
// Compare match interrupt T001
#define ENABLE_T3_COMPA_INT()       { TMMK000 = 0; }
#define DISABLE_T3_COMPA_INT()      { TMMK000 = 1; }
#define CLEAR_T3_COMPA_INT()        { TMIF000 = 0; }

// Compare match interrupt T001
#define ENABLE_T3_COMPB_INT()       { TMMK010 = 0; }
#define DISABLE_T3_COMPB_INT()      { TMMK010 = 1; }
#define CLEAR_T3_COMPB_INT()        { TMIF010 = 0; }


/*******************************************************************************************************
 *******************************************************************************************************
 **************************                   USEFUL STUFF                    **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//-------------------------------------------------------------------------------------------------------
//  void halWait(UINT16 timeout)
//
//  DESCRIPTION:
//      Runs an idle loop for [timeout] microseconds.
//
//  ARGUMENTS:
//      UINT16 timeout
//          The timeout in microseconds
//-------------------------------------------------------------------------------------------------------
void halWait(UINT16 timeout);




/*******************************************************************************************************
 *******************************************************************************************************
 **************************                   EEPROM ACCESS                   **************************
 *******************************************************************************************************
 *******************************************************************************************************/


//-------------------------------------------------------------------------------------------------------
//  void halWriteAdress(BYTE *pData)
//
//  DESCRIPTION:
//	Writes address into FLASH memory
//
//  ARGUMENTS:
//      BYTE *pData
//          A pointer to the write buffer
//-------------------------------------------------------------------------------------------------------
void halWriteAddress(BYTE *pData);


//-------------------------------------------------------------------------------------------------------
//  halReadAdress(BYTE *pData)
//
//  DESCRIPTION:
//      Reads address from FLASH
//
//  ARGUMENTS:
//      BYTE *pData
//          A pointer to the read buffer
//-------------------------------------------------------------------------------------------------------
void halReadAddress(BYTE *pData);




/*******************************************************************************************************
 *******************************************************************************************************
 **************************              SIMPLE CC2420 FUNCTIONS              **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//-------------------------------------------------------------------------------------------------------
//  Example of usage: Starts RX on channel 14 after reset
//      FASTSPI_RESET_CC2420();
//      FASTSPI_STROBE(CC2420_SXOSCON);
//      halRfSetChannel(14);
//      ... other registers can for instance be initialized here ...
//      halRfWaitForCrystalOscillator();
//      ... RAM access can be done here, since the crystal oscillator must be on and stable ...
//      FASTSPI_STROBE(CC2420_SRXON);
//-------------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------------
//  void rfWaitForCrystalOscillator(void)
//
//  DESCRIPTION:
//      Waits for the crystal oscillator to become stable. The flag is polled via the SPI status byte.
//
//      Note that this function will lock up if the SXOSCON command strobe has not been given before the
//      function call. Also note that global interrupts will always be enabled when this function
//      returns.
//-------------------------------------------------------------------------------------------------------
void halRfWaitForCrystalOscillator(void);


//-------------------------------------------------------------------------------------------------------
//  void halRfSetChannel(UINT8 Channel)
//
//  DESCRIPTION:
//      Programs CC2420 for a given IEEE 802.15.4 channel.
//      Note that SRXON, STXON or STXONCCA must be run for the new channel selection to take full effect.
//
//  PARAMETERS:
//      UINT8 channel
//          The channel number (11-26)
//-------------------------------------------------------------------------------------------------------
void halRfSetChannel(UINT8 channel);


#endif



/*******************************************************************************************************
 * Revision history:
 *
 * $Log: hal.h,v $
 * Revision 1.0  2004/12/11 13:00:00  fr
 * CC2420 MAC Release v0.7
 *
 *
 *******************************************************************************************************/

⌨️ 快捷键说明

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