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

📄 cc1110 sleep.txt

📁 讲述了CC1110sleep的设置
💻 TXT
📖 第 1 页 / 共 4 页
字号:
      }                                            \   
      else {                                       \   
         if(channel == 0x01){                      \   
            IO_FUNC_PORT_PIN(0,3,IO_FUNC_PERIPH);  \   
         }                                         \   
         else {                                    \   
            IO_FUNC_PORT_PIN(0,4,IO_FUNC_PERIPH);  \   
         }                                         \   
      }                                            \   
   } while(0)   
   
// Where _edge_ is either    
#define POS_EDGE 0x01  // Capture when a positive edge on the channel input is detected    
#define NEG_EDGE 0x02  // Capture when a negative edge on the channel input is detected    
#define ANY_EDGE 0x03  // Capture when either a positive or a negative edge on the    
                       // channel input is detected.    
   
// Macro for enabling or disabling overflow interrupts of timer 1.    
#define TIMER1_ENABLE_OVERFLOW_INT(val) \    
   (TIMIF =  (val) ? TIMIF | 0x40 : TIMIF & ~0x40)   
   
   
   
   
/******************************************************************************  
* @fn  halSetTimer2Period  
*  
* @brief  
*      This function sets the period timer 2. The values for the counter,  
*      prescaler and tick period is calculated and written to the corresponding  
*      registers.  
*  
* Parameters:  
*  
* @param  uint32 period  
*         Period of the timer in u-seconds.  
* @param  uint8* cnt  
*         The value written to T2CT (counter). This value is returned to enable  
*         a fast setup (without calculation) using the SET_TIMER2_COUNTER.  
* @param  uint8* presc  
*         The value written to T2PR (prescaler). This value is returned to enable  
*         a fast setup (without calculation) using the SET_TIMER2_PRESCALER.  
*  
* @return bool  
          Returns FALSE if period is too large, TRUE otherwise.  
*  
******************************************************************************/   
bool halSetTimer2Period(uint32 period, uint8* cnt, uint8* presc);   
   
#define TIMER2_INIT()  \    
   do {                \   
      T2CTL = 0x00;    \   
      T2CT = 0x00;     \   
      T2PR = 0x00;     \   
   } while (0)   
   
#define TIMER2_SET_COUNTER(counter) do{ T2CT = counter; }while(0)    
#define TIMER2_SET_PRESCALER(prescaler) do{ T2PR = prescaler; }while(0)    
#define TIMER2_SET_TICK_PERIOD(tick) do{ T2CTL = ((T2CTL & ~0x03) | tick); }while(0)    
#define TIMER2_ENABLE_INTERRUPT() do{ T2CTL |= 0x10; }while(0)    
#define TIMER2_DISABLE_INTERRUPT() do{ T2CTL &= ~0x10; }while(0)    
#define TIMER2_CLEAR_EXPIRED() do{ T2CTL &= ~0x40; }while(0)    
#define TIMER2_EXPIRED (T2CTL & 0x40)    
#define TIMER2_SET_MODE(mode)      (T2CTL  = (mode) ? T2CTL|0x04  : T2CTL&~0x04)    
   
#define TIMER2_USE_REG  FALSE    
#define TIMER2_FREE     TRUE    
   
/******************************************************************************  
* @fn  halSetTimer34Period  
*  
* @brief  
*      This function sets the period of timer 3 or 4 according to the value of  
*      _timer_. The two timers are identical. Clock division is used to fit the  
*      desired period within the timer range. If the period is too short or too  
*      long the function returns 0. If the period is successfully set, the  
*      function returns the byte value written to the timer register. This  
*      value can be used to set the pulse length if the timer is used for PWM.  
*      If _period_ is set to 0, maximum timeout value will be used.  
*  
* Parameters:  
*  
* @param  byte   timer  
*         Indicates which timer to configure. Must be either 3 or 4  
*         (0x03 or 0x04).  
* @param  dword  period - Describe value.  
*         The desired period in microseconds.  
*  
* @return byte  
*         The value written to the TxCC0 register. The timer is incremented up  
*         to this value before the timer is reset. This value may be used to  
*         set the pulse length in PWM mode.  
*  
******************************************************************************/   
byte halSetTimer34Period(byte timer, dword period);   
// Where _timer_ must be either 3 or 4    
   
// Macro for initialising timer 3 or 4    
#define TIMER34_INIT(timer)   \    
   do {                       \   
      T##timer##CTL   = 0x06; \   
      T##timer##CCTL0 = 0x00; \   
      T##timer##CC0   = 0x00; \   
      T##timer##CCTL1 = 0x00; \   
      T##timer##CC1   = 0x00; \   
   } while (0)   
   
//Macro for enabling overflow interrupt    
#define TIMER34_ENABLE_OVERFLOW_INT(timer,val) \    
   (T##timer##CTL =  (val) ? T##timer##CTL | 0x08 : T##timer##CTL & ~0x08)   
   
   
   
// Macro for configuring channel 1 of timer 3 or 4 for PWM mode.    
#define TIMER34_PWM_CONFIG(timer)                 \    
   do{                                            \   
      T##timer##CCTL1 = 0x24;                     \   
      if(timer == 3){                             \   
         if(PERCFG & 0x20) {                      \   
            IO_FUNC_PORT_PIN(1,7,IO_FUNC_PERIPH); \   
         }                                        \   
         else {                                   \   
            IO_FUNC_PORT_PIN(1,4,IO_FUNC_PERIPH); \   
         }                                        \   
      }                                           \   
      else {                                      \   
         if(PERCFG & 0x10) {                      \   
             IO_FUNC_PORT_PIN(2,3,IO_FUNC_PERIPH);\   
         }                                        \   
         else {                                   \   
            IO_FUNC_PORT_PIN(1,1,IO_FUNC_PERIPH); \   
         }                                        \   
      }                                           \   
   } while(0)   
   
// Macro for setting pulse length of the timer in PWM mode    
#define TIMER34_SET_PWM_PULSE_LENGTH(timer, value) \    
   do {                                            \   
      T##timer##CC1 = (byte)value;                 \   
   } while (0)   
   
   
// Macro for setting timer 3 or 4 as a capture timer    
#define TIMER34_CAPTURE_TIMER(timer,edge)          \    
   do{                                             \   
      T##timer##CCTL1 = edge;                      \   
      if(timer == 3){                              \   
         if(PERCFG & 0x20) {                       \   
            IO_FUNC_PORT_PIN(1,7,IO_FUNC_PERIPH);  \   
         }                                         \   
         else {                                    \   
             IO_FUNC_PORT_PIN(1,4,IO_FUNC_PERIPH); \   
         }                                         \   
      }                                            \   
      else {                                       \   
         if(PERCFG & 0x10) {                       \   
            IO_FUNC_PORT_PIN(2,3,IO_FUNC_PERIPH);  \   
         }                                         \   
        else {                                     \   
           IO_FUNC_PORT_PIN(1,1,IO_FUNC_PERIPH);   \   
        }                                          \   
     }                                             \   
  }while(0)   
   
   
// Macros for turning timers on or off    
#define TIMER1_RUN(value)      (T1CTL = (value) ? T1CTL|0x02 : T1CTL&~0x03)    
#define TIMER3_RUN(value)      (T3CTL = (value) ? T3CTL|0x10 : T3CTL&~0x10)    
#define TIMER4_RUN(value)      (T4CTL = (value) ? T4CTL|0x10 : T4CTL&~0x10)    
   
// Macro for enabling/ disabling interrupts from the channels of timer 1, 3 or 4.    
#define TIMER_CHANNEL_INTERRUPT_ENABLE(timer, channel, value) \    
   do{                                                        \   
      if(value){                                              \   
         T##timer##CCTL##channel## |= 0x40;                   \   
      } else {                                                \   
         T##timer##CCTL##channel## &= ~0x40;                  \   
      }                                                       \   
   } while(0)   
   
// Sleep Timer / Wake On Radio (WOR) Timer    
   
//Macro for initialising the sleep timer / WOR timer.    
#define SLEEP_TIMER_INIT()                                    \    
   do{                                                        \   
      WOREVT1 = 0x87;                                         \   
      WOREVT0 = 0x6B;                                         \   
      WORCTL = 0x74;                                          \   
      WORIRQ = 0x00;                                          \   
   } while(0)   
   
// Macros for enabling / disabling interrupt for event 0 and 1.    
#define SLEEP_TIMER_ENABLE_EVENT0_INT(val) do{ WORIRQ = (val) ? WORIRQ | 0x10 : WORIRQ & ~0x10; }while(0)    
#define SLEEP_TIMER_ENABLE_EVENT1_INT(val) do{ WORIRQ = (val) ? WORIRQ | 0x20 : WORIRQ & ~0x20; }while(0)    
   
// Macro for resetting the Sleep / WOR timer    
#define SLEEP_TIMER_RESET()      WORCTL |= 0x04    
   
   
   
   
/******************************************************************************  
*******************          Watch Dog Timer (WDT)          *******************  
*******************************************************************************  
  
The WDT may be used to prevent the unit from being trapped in a system  
stalemate, i.e. an endless waiting state. The WDT must be reset before it times  
out. If a timeout occurs, the system is reset.  
  
The WDT can also be configured as a normal timer which generates interrupt at  
each timeout. This must be configured manually.  
******************************************************************************/   
   
// Macro for setting the WDT timeout interval.    
#define WDT_SET_TIMEOUT_PERIOD(timeout) \    
   do {  WDCTL &= ~0x03; WDCTL |= timeout; } while (0)   
   
// Where _timeout_ is one of    
#define SEC_1          0x00     // after 1 second    
#define M_SEC_250      0x01     // after 250 ms    
#define M_SEC_15       0x02     // after 15 ms    
#define M_SEC_2        0x03     // after 2 ms    
   
// Macro for resetting the WDT. If this is not done before the WDT times out,    
// the system is reset.    
#define WDT_RESET() do {           \    
   WDCTL = (WDCTL & ~0xF0) | 0xA0; \   
   WDCTL = (WDCTL & ~0xF0) | 0x50; \   
} while (0)   
   
// Macro for turning on the WDT    
#define WDT_ENABLE()   WDCTL |= 0x08    
#define WDT_DISABLE()  WDCTL &= ~0x08    
   
   
   
   
/******************************************************************************  
*******************             ADC macros/functions        *******************  
*******************************************************************************  
  
These functions/macros simplifies usage of the ADC.  
  
******************************************************************************/   
// Macro for setting up a single conversion. If ADCCON1.STSEL = 11, using this    
// macro will also start the conversion.    
#define ADC_SINGLE_CONVERSION(settings) \    
   do{ ADCCON3 = settings; }while(0)   
   
// Macro for setting up a single conversion    
#define ADC_SEQUENCE_SETUP(settings) \    
   do{ ADCCON2 = settings; }while(0)   
   
// Where _settings_ are the following:    
// Reference voltage:    
#define ADC_REF_1_25_V      0x00     // Internal 1.25V reference    
#define ADC_REF_P0_7        0x40     // External reference on AIN7 pin    
#define ADC_REF_AVDD        0x80     // AVDD_SOC pin    
#define ADC_REF_P0_6_P0_7   0xC0     // External reference on AIN6-AIN7 differential input    
   
// Resolution (decimation rate):    
#define ADC_8_BIT           0x00     //  64 decimation rate    
#define ADC_10_BIT          0x10     // 128 decimation rate    
#define ADC_12_BIT          0x20     // 256 decimation rate    
#define ADC_14_BIT          0x30     // 512 decimation rate    
// Input channel:    
#define ADC_AIN0            0x00     // single ended P0_0    
#define ADC_AIN1            0x01     // single ended P0_1    
#define ADC_AIN2            0x02     // single ended P0_2    
#define ADC_AIN3            0x03     // single ended P0_3    
#define ADC_AIN4            0x04     // single ended P0_4    
#define ADC_AIN5            0x05     // single ended P0_5    
#define ADC_AIN6            0x06     // single ended P0_6    
#define ADC_AIN7            0x07     // single ended P0_7    
#define ADC_GND             0x0C     // Ground    
#define ADC_TEMP_SENS       0x0E     // on-chip temperature sensor    
#define ADC_VDD_3           0x0F     // (vdd/3)    
   
   
//-----------------------------------------------------------------------------    
// Macro for starting the ADC in continuous conversion mode    
#define ADC_SAMPLE_CONTINUOUS() \    
   do { ADCCON1 &= ~0x30; ADCCON1 |= 0x10; } while (0)   
   
// Macro for stopping the ADC in continuous mode (and setting the ADC to be    
// started manually by ADC_SAMPLE_SINGLE() )    
#define ADC_STOP() \    
  do { ADCCON1 |= 0x30; } while (0)   
   
// Macro for initiating a single sample in single-conversion mode (ADCCON1.STSEL = 11).    
#define ADC_SAMPLE_SINGLE() \    
  do { ADC_STOP(); ADCCON1 |= 0x40;  } while (0)   
   
// Macro for configuring the ADC to be started from T1 channel 0. (T1 ch 0 must be in compare mode!!)    
#define ADC_TRIGGER_FROM_TIMER1()  do { ADC_STOP(); ADCCON1 &= ~0x10;  } while (0)    
   
// Expression indicating whether a conversion is finished or not.    
#define ADC_SAMPLE_READY()  (ADCCON1 & 0x80)    
   
// Macro for setting/clearing a channel as input of the ADC    
#define ADC_ENABLE_CHANNEL(ch)   ADCCFG |=  (0x01<<CH) \ do{ #define } byte { for 0x03 0x02 at 0x01 0x00 transfer channel interrupt each bytes 1 by 0 data encryption AES input sample in conversion of ADC a received packet RF 16 14 12 compare is bit setting word time first the number 0x04 with 0x10 0x08 ****************************************************************************** usage and simplify section this macros The (0) while if &="~(0x01<<ch)" |="0x40;" do usage: Example or set to used Macro ) ( 0x20 one Where enable code flags which Macros ******************* functions where ADCCFG pre < ------------------------------------------------------------------------------* [gary] By:cuiqingwei Modify \_) (_ ooo0 0ooo *------------------------------------------------------------------------------ HAL_H #endif wait); halWait(byte void * @return wait. m-seconds wait @param Parameters: speed. clock main regardless given approximately waits function This @brief halWait @fn Utility halInitRandomGenerator(void); generator. random clocking new generating basis forms seeding seed receiver. from sampled on turned radio radio. using sequence generates halInitRandomGenerator }while(0) RNDL); 8) << CLOCK_RANDOM_GENERATOR(); GET_RANDOM_WORD(a) getting GET_RANDOM_BYTE(a) while(0) ADCCON1 CLOCK_RANDOM_GENERATOR() generator ENABLE_RANDOM_GENERATOR() enabling rnd="GET_RANDOM_VALUE();" read): (clock be should following read, Each halInitRandomGenerator(); generator: initialise rnd; ************ Generator Random ************* ENCCS AES_START() loading. vector initialisation key decryption, encryption, either module starting 0x06 AES_LOAD_IV AES_LOAD_KEY AES_DECRYPT AES_ENCRYPT _mode_ mode; ~0x07) AES_SET_ENCR_DECR_KEY_IV(mode) decryption stopping 0x50 CBC_MAC 0x40 ECB 0x30 CTR OFB CFB CBC AES_SETMODE(mode) operation mode DECRYPT ENCRYPT AES_BUSY decr); bool pInitVector, byte* pDataOut, length, uint16 pDataIn, halAesEncrDecr(byte* decryption. indicates whereas performed. an whether Indicates decr identical Must startup. fill Initialisation pInitVector stored. converted location Pointer pDataOut. bytes. multiplum Should decrypted. encrypted length decrypted start pDataIn location. result stores decrypts Encrypts halAesEncrDecr key); pData, halAesLoadKeyOrInitVector(byte* loaded. FALSE loaded TRUE Set value. Boolean pData bit). (128 long must vector) (key vector. Loads halAesLoadKeyOrInitVector module. also may (DMA) Access Memory Direct manual performs process. prior unique A Standard. Encryption Advanced performing Functions ******************************************************************************* MEMCTR DISABLE_UINIFIED_CODE_SPACE() ENABLE_UINIFIED_CODE_SPACE() RAM. programs executing when generally space Unified space. unified disabling ******************** mapping 0x07; NO_OP 0x06; REGZ_IS_0 0x05; REGY_IS_0 0x04; REGX_IS_0 0x03; COMMAND_BUF_EMPT 0x02; MCU_BIT_IS_1 0x01; RECEIVING 0x00; CCA_TRUE CSP instructions SKIP RPT _c_ Conditions ------------------------------------------------------------------------------------------------------ do{RFST="0x00;}while(0)" SNOP() SAFC() SIDLE() STX() SRX() SCAL() SFSTXON() Strobes Command PA_POWER_0 0x07 PA_POWER_7 CALIBRATE_EVERY_4TH CALIBRATE_WHEN_COMING_FROM_IDLE RX_AFTER_TX 0x0C STAY_INR_RX_AFTER_RX VARIABLE_PKT_LEN CRC_EN WHITE_DATA APPEND_STATUS settings Various SFD_FLAG) (PKTSTATUS SFD CCA_FLAG) CCA PQT_REACHED_FLAG) PQT_REACHED CS_FLAG) CS CRC_OK_FLAG) CRC_OK states status Radio SFD_FLAG CCA_FLAG PQT_REACHED_FLAG CS_FLAG 0x80 CRC_OK_FLAG IRQ_SFD IRQ_CCA IRQ_PQT IRQ_CS IRQ_DONE IRQ_TIMEOUT SIDLE(); STOP_RADIO() frequency); halRfSetRadioFrequency(uint32 kHz. Frequency desired frequency range within requency sets halRfSetRadioFrequency halRfConfig(uint32 otherwise. successful configuration Returns uint32 successful. returns set. corruption. detection calculated automatically value CRC employed. not etc AutoAck Decoding, Address as such functionality 802.15.4 IEEE operation. receive send simple configures halRfConfig timeOut); pLqi, byte*pRssi, halRfReceivePacket(byte* received. will chip ms timeOut indicator. quality link store pLqi calculation. indicator strength signal pRssi data. any receiving without returning before _timeOut_ transmitter. another sent 128 maximum receives halRfReceivePacket length); halRfSendPacket(byte* transferred transferred. complete. until 125 Can sending. sends halRfSend included. are Processor Stobe writing addition, In receiption transmitting setup, designed communication halGetAdcValue(void); int16 conversion. last halGetAdcValue input); uint8 resolution, reference, halAdcSampleSingle(byte sampled. bit) 10, (8, during use resolution reference reference. adc makes halAdcSampleSingle ADC_DISABLE_CHANNEL(ch)>

⌨️ 快捷键说明

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