Silicon Laboratories Si4012 Скачать руководство пользователя страница 23

AN746

Rev. 0.1

23

5.3.3. SPI Driver

The SPI related source files, called 

spi.h and spi.c

, can be found in the /src/driver/ folder. To enable the SPI

interface the SPI port has to be enabled and associated to the crossbar. The directions of the SCK, MISO and
MOSI ports have to be configured properly on the IO port. Finally, the default states of the pins have to be set
correctly. Since several devices can be connected to the same SPI bus, the NSEL pin of the selected device is
activated during communication. Since the commands to be sent to the API are sequences of bytes, the module
has to be able to send and receive continuous byte stream. There are some cases when either reading a single
byte directly from the MISO or writing specified number of bits directly to the MOSI is necessary. In order to cover
these kinds of cases, “bitbang” read/write methods have been also implemented.

5.3.4. Timer Peripheral Driver

The timer related source files, called 

timer.h

 and 

timer.c

, can be found in 

the /src/drivers/

 folder. The module

handles two 16-bit timers, timer2 and timer3. The most accurate timing interval   can be calculated from the
frequency of the system clock which is generally 24.5 MHz. External clock sources can be selected as timer input
and moreover the required timing frequency can be adjusted thoroughly with several different prescalers. In
general, the timer settings belonging to the so-called heart-beat frequency of 1 kHz (1 ms) are prepared. Using the
timer with the 1 ms settings, timeouts multiple of 1 ms can be easily implemented. Timer related operations can
give possibilities to start or stop counting. Additionally, interrupts can be generated when the low byte of the timer
overflows. Timers can also be checked whether get expired or not.

U8

 

bSpi_ReadWriteSpi1

(

U8

 

biDataIn);

 

void

 

vSpi_EnableSpi1

(

void

);

 

void

 

vSpi_DisableSpi1

(

void

);

 

void

 

vSpi_ClearNselSpi1

(

U8

 

biSelectDevice);

 

void

 

vSpi_SetNselSpi1

(

U8

 

biSelectDevice);

 

void

 

vSpi_WriteDataSpi1

(

U8

 

biDataInLength,

 

U8

 

*pabiDataIn);

 

void

 

vSpi_ReadDataSpi1

(

U8

 

biDataOutLength,

 

U8

 

*paboDataOut);

 

U8

 

bSpi_ReadByteBitbangSpi1

(

void

);

 

void

 

vSpi_WriteBitsBitbangSpi1

(

U8

 

biDataIn,

 

U8

 

biNumOfBits);

 

void

  

vTmr_InitTmr2

(

void

);

 

void

  

vTmr_StartTmr2

(

U8

 

biPrescaler,

 

U16

 

wiPeriod,

 

U8

 

biItEnable,

 

U8

 

biExtClkSel);

 

BIT

   

gTmr_Tmr2Expired

(

void

);

 

void

  

vTmr_StartTmr3

(

U8

 

biPrescaler,

 

U16

 

wiPeriod,

 

U8

 

biItEnable,

 

U8

 

biExtClkSel);

 

UU16

  

wwTmr_GetTmr3

(

void

);

 

BIT

   

gTmr_Tmr3Expired

(

void

);

 

Содержание Si4012

Страница 1: ...following operation examples are covered in the programming guide How to configure the Si4012 How to use the Si4012 transmitter for packet transmission in FIFO mode How to measure battery voltage The...

Страница 2: ...that contains an EZRadio IC matching network and pcb antenna The RF output is selectable between the PCB antenna and a 50 SMA output connector via a 0 resistor The boards also have a factory loaded bo...

Страница 3: ...P3 Since JP3 is shorted by a PCB track on the bottom side of the board the user have to cut the track if this feature is used Steps of connecting the platform to a PC Connect an RF Pico Board to the L...

Страница 4: ...C8051F930 that is used on the hardware platforms described in this document The Silicon Laboratories IDE integrates a project manager a source code editor source level debugger and an in system flash...

Страница 5: ...the host configured as master and the Si4012 as slave Both standard 100 kbs and fast 400 kbs modes are supported with 7 bit addressing The device address is 1110000x where x is the R W bit Since shut...

Страница 6: ...AN564 Si4012 Calculator Spreadsheet Usage available at www silabs com The user inputs the required values into the spreadsheet Center frequency Modulation type FSK deviation Total PA power Bit rate a...

Страница 7: ...stant arrays have to be initialized with the defined commands first Here is the corresponding part of the example program arrays initialized with precompiled commands SEGMENT_VARIABLE C_CHIP_CONFIG U8...

Страница 8: ...to the host The host should poll the NIRQ pin or use interrupts NIRQ to get interrupt status The host can then read the interrupt status of the radio with GET_INT_STATUS command that also clears the...

Страница 9: ...f Si4012 is in sensor mode and low battery interrupt is enabled The period and threshold can be set in the LBD_CONFIG property 4 6 Crystal Oscillator Tuning Capacitor When crystal is used the accuracy...

Страница 10: ...license for Keil s C51 compiler you may need to unlock it to 4k as some project s size exceeds the 2k code size limit However the sample projects can be complied not only with the two mentioned compi...

Страница 11: ...shows the software layers and its relations The individual software modules are separated into several source files In the sample projects there is one header file that is included in the source files...

Страница 12: ...o chip This project is the essential core of the following three sample codes CW_Transmit PN9 TX It is primarily responsible for initializing the MCU and RFIC as well It also initializes the Human Mac...

Страница 13: ...upt Finally it enables the MCU related internal interrupts In the main function the SampleCode_Demo_Pollhandler is responsible for several tasks 1 It checks if the Si4012 Pico board is connected to th...

Страница 14: ...AN746 14 Rev 0 1...

Страница 15: ...xt state will execute the user application code 3 SM_STEP2 User application code can be started from this point The state of SM_STEP1 simply configures the chip by calling the Si4012_Configure functio...

Страница 16: ...shortly thereafter To illustrate how to expand the code with dynamic behavior SM_STEP2 provides the user with a clear example of how to use the LCD baseboard push buttons for turning in out the CW tra...

Страница 17: ...llustrate how to expand the code with dynamic behavior SM_STEP2 provides the user with a clear example of how to use the LCD baseboard push buttons for turning in out the PN 9 transmission After start...

Страница 18: ...AN746 18 Rev 0 1...

Страница 19: ...sure error free packet reception The two byte CRC is implemented in the CRC h module by CRC_CalculateCRC16 U8 pbInputData U8 bLengthOfInputData function The Si4012 related functions are implemented in...

Страница 20: ...n added to the project in order to enable the Si4012_Configure function to initialize the radio chip During the configuration the Si4012_SetProperty function will initialize the API properties by send...

Страница 21: ...AN746 Rev 0 1 21 The additional header files should be included in the common bsp h located in the src drivers directory The bsp h file already contains included headers...

Страница 22: ...ponsible for handling the dedicated internal peripherals such as the IO the timers the SPI and the PCA The HMI holds them together so it gives a higher abstraction level to the User Application in for...

Страница 23: ...terval can be calculated from the frequency of the system clock which is generally 24 5 MHz External clock sources can be selected as timer input and moreover the required timing frequency can be adju...

Страница 24: ...n event is always available first amongst the unhandled events HANDLERS Start the push button handler void vHmi_InitPbHandler void Start the Led handler void vHmi_InitLedHandler void Start the Buzzer...

Страница 25: ...zState void vHmi_BuzzHandler void typedef enum _eHmi_BuzzStates eHmi_BuzzOff_c 0x00 Buzz is in off state eHmi_BuzzStdBy_c 0x01 Buzz waits for state change eHmi_BuzzOn_c 0x10 Buzz is in on state eHmi_B...

Страница 26: ...dure The main function in the empty project is as follows User defined init functions should be placed before the while loop The vInitializeHW looks as follows The radio_config h configuration should...

Страница 27: ...d custom configurations to this file radio_hal h Common hardware abstraction layer for both Si446x and Si4455 radio families radio_comm h Common communication layer for both Si446x and Si4455 radio fa...

Страница 28: ...bs hardware platform This may be modified according to the new architecture and hardware spi c spi h The SPI driver module shall be supplied to enable the communication with the radio radio_hal c radi...

Страница 29: ...AN746 Rev 0 1 29 NOTES...

Страница 30: ...th which if it fails can be reasonably expected to result in significant personal injury or death Silicon Laboratories products are generally not intended for military applications Silicon Laboratorie...

Отзывы: