This example sends packets every 20 ms and uses "register retention" power save mode to minimize power consumption.
The contents of P0 are sent in the first payload byte (byte 0).
Protocol parameters such as addresses and channels are specified in gazell_examples/params/gzll_params.h.
The project Gazell Link Layer Host example can be used as a counterpart for receiving the data.
Functions | |
void | main (void) |
void main | ( | void | ) |
Definition at line 40 of file main.c.
{ uint8_t poll_cnt = 0; uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH]; mcu_init(); gzll_init(); // Always run on 16MHz crystal oscillator hal_clk_set_16m_source(HAL_CLK_XOSC16M); //wait for external crystal to activate while(hal_clk_get_16m_source() != HAL_CLK_XOSC16M){} // Use Gazell Link Layer synchronous device mode 2 for minimizing // transmit attempts gzll_set_param(GZLL_PARAM_DEVICE_MODE, 2); EA = 1; for(;;) { // If gazell link layer idle if(gzll_get_state() == GZLL_IDLE) { // Send a packet for every 20 wakeup, equals every ~20 ms if(poll_cnt > 20) { // Read P0 and put in payload[0] payload[0] = ~P0; // Transmits 1 byte ( payload[0] ) to pipe 0 address gzll_tx_data(&payload[0], 1, 0); poll_cnt = 0; } } EA = 0; // If radio not active, enter "register retention" if(!gzll_radio_active()) { PWRDWN = 0x04; // Enter "register retention", will wake up on pre-tick } PWRDWN = 0x07; // Enter "standby", will wake up on tick EA = 1; poll_cnt++; } }