BlueNRG-1 peripheral
driver examples
UM2264
44/55
DocID030868 Rev 1
PUSH1
: toggle LED DL1
15.5
RTC examples
Clock watch:
implements both RTC timer and RTC clockwatch.
The RTC timer generates the 500 ms interrupt interval. The LED DL1 state is toggled in the
RTC interrupt handler to signal proper RTC timer operation.
The RTC clockwatch is also enabled with the system time and date set to December 1
st
2014, 23 h 59 m 31 s. The RTC clockwatch match registers are then set to December 2
nd
2014, 0 h 0 m 1 s. As soon as the RTC clockwatch data register and match registers
coincide (30 s after device power up), the RTC clockwatch match interrupt is generated
and LED DL2 is toggled to signal the event.
Time base
: the RTC is configured in the periodic timer mode, the load register
(RTC_TLR1) value is set and the RTC is enabled. Whenever the RTC timer reaches the
value 0x00 it generates an interrupt event and the timer value is automatically re-loaded
from the RTC_TLR1 register, which is set to generate the interrupt every 1 s. The LED DL1
is toggled at each interrupt event.
Time base pattern
: periodic mode is used with a pattern configuration. The RTC is
configured in the periodic timer mode and register RTC_TLR1 is set to generate a 1 s
interval, while RTC_TLR2 is set to generate a 100 ms interval.
The RTC is then enabled and whenever the RTC timer reaches the value 0x00 it generates
an interrupt and the timer value is automatically re-loaded from register RTC_TLR1 or
RTC_TLR2 register depending on the pattern register setting.
The pattern size is set to 8 bits and the pattern is set to 0b11110010, so the RTC
generates four intervals with the RTC_TLR1 value followed by two RTC_TLR2 value
intervals. The pattern repeats itself and the RTC interrupt routine toggles LED DL1 (IO6).
15.6
SPI examples
The following SPI application examples are available:
Master polling
: involves a master board with the Master_Polling firmware code and a
slave board with the Slave_Polling firmware. The Master board has a small command line
interface through UART (USB-to-SERIAL must be connected to the PC), which you can
use to read and change the LED status of the slave board via SPI.
The SPI is configured in master mode and the SPI clock set to 100 kHz. The data is
transferred in the Motorola format with an 8-bit data frame, with clock low when inactive
(CPOL=0) and data valid on clock trailing edge (CPHA = 1).
Slave polling
: SPI communication is controlled by polling the SPI status register content.
This also involves a master and a slave board with respective Master_Polling and
Slave_Polling firmware. The slave board receives read and change requests for the LEDs
via SPI.
The SPI is configured in slave mode and the SPI clock set to 100 kHz. The data is
transferred in the Motorola format with an 8-bit data frame, with clock low when inactive
(CPOL=0) and data valid on clock trailing edge (CPHA = 1).
Master sensor
: SPI communication is controlled by polling of the SPI status register
content, interrupts or DMA (3 different configurations). SPI is used to communicate with the
LSM6DS3 inertial sensor SPI interface. Whenever the sensor generates an IRQ, the
accelerometer and gyroscope output data are read and printed through UART (USB-to-
SERIAL must be connected to the PC).