ST Expansion SW Team / Mbed OS mbed-os-nfc05a1

Dependencies:   RFAL ST25R3911 BSP05

Committer:
DiegoOstuni
Date:
Thu Nov 14 14:57:00 2019 +0000
Revision:
3:9a152c93d7a2
Parent:
1:86504e1ac6b1
Example application for the STMicroelectronics X-NUCLEO-NFC05A1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DiegoOstuni 1:86504e1ac6b1 1 #include "x_nucleo_nfc05.h"
DiegoOstuni 1:86504e1ac6b1 2
DiegoOstuni 1:86504e1ac6b1 3
DiegoOstuni 1:86504e1ac6b1 4
DiegoOstuni 1:86504e1ac6b1 5 /**
DiegoOstuni 1:86504e1ac6b1 6 * @brief Constructor of the NFC05A1 class
DiegoOstuni 1:86504e1ac6b1 7 * @param spiChannel: SPI Channel
DiegoOstuni 1:86504e1ac6b1 8 * @param led_1: Digital Led
DiegoOstuni 1:86504e1ac6b1 9 */
DiegoOstuni 1:86504e1ac6b1 10 X_Nucleo_NFC05::X_Nucleo_NFC05(SPI *spiChannel, DigitalOut *led_1)
DiegoOstuni 1:86504e1ac6b1 11 {
DiegoOstuni 1:86504e1ac6b1 12
DiegoOstuni 1:86504e1ac6b1 13 mspiChannel = spiChannel;
DiegoOstuni 1:86504e1ac6b1 14 mled_1 = led_1;
DiegoOstuni 1:86504e1ac6b1 15 }
DiegoOstuni 1:86504e1ac6b1 16
DiegoOstuni 1:86504e1ac6b1 17 /**
DiegoOstuni 1:86504e1ac6b1 18 * @brief This function initialize the device
DiegoOstuni 1:86504e1ac6b1 19 * @param spiChannel : SPI Channel
DiegoOstuni 1:86504e1ac6b1 20 * @retval void
DiegoOstuni 1:86504e1ac6b1 21 */
DiegoOstuni 1:86504e1ac6b1 22
DiegoOstuni 1:86504e1ac6b1 23 void X_Nucleo_NFC05::begin(SPI *mspiChannel) {
DiegoOstuni 1:86504e1ac6b1 24
DiegoOstuni 1:86504e1ac6b1 25 }
DiegoOstuni 1:86504e1ac6b1 26
DiegoOstuni 1:86504e1ac6b1 27
DiegoOstuni 1:86504e1ac6b1 28 /**
DiegoOstuni 1:86504e1ac6b1 29 * @brief This function light on selected Led
DiegoOstuni 1:86504e1ac6b1 30 * @param led : Led to be lit on
DiegoOstuni 1:86504e1ac6b1 31 * @retval None
DiegoOstuni 1:86504e1ac6b1 32 */
DiegoOstuni 1:86504e1ac6b1 33 void X_Nucleo_NFC05::ledOn(DigitalOut* led) {
DiegoOstuni 1:86504e1ac6b1 34 led -> write(1);
DiegoOstuni 1:86504e1ac6b1 35 }
DiegoOstuni 1:86504e1ac6b1 36
DiegoOstuni 1:86504e1ac6b1 37 /**
DiegoOstuni 1:86504e1ac6b1 38 * @brief This function light off selected Led
DiegoOstuni 1:86504e1ac6b1 39 * @param led : Led to be lit off
DiegoOstuni 1:86504e1ac6b1 40 * @retval None
DiegoOstuni 1:86504e1ac6b1 41 */
DiegoOstuni 1:86504e1ac6b1 42
DiegoOstuni 1:86504e1ac6b1 43 void X_Nucleo_NFC05::ledOff(DigitalOut* led) {
DiegoOstuni 1:86504e1ac6b1 44 *led = 0;
DiegoOstuni 1:86504e1ac6b1 45 }
DiegoOstuni 1:86504e1ac6b1 46
DiegoOstuni 1:86504e1ac6b1 47 // WHAT OTHER FUNCTION WE WANT? WRITE URI AND READ URI? WHAT ELSE?
DiegoOstuni 1:86504e1ac6b1 48
DiegoOstuni 1:86504e1ac6b1 49 void spiInitMain(SPI_HandleTypeDef hspi1, SPI_InitTypeDef Init){
DiegoOstuni 1:86504e1ac6b1 50
DiegoOstuni 1:86504e1ac6b1 51 hspi1.Instance = SPI1;
DiegoOstuni 1:86504e1ac6b1 52 hspi1.Init.Mode = SPI_MODE_MASTER;
DiegoOstuni 1:86504e1ac6b1 53 hspi1.Init.Direction = SPI_DIRECTION_2LINES;
DiegoOstuni 1:86504e1ac6b1 54 hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
DiegoOstuni 1:86504e1ac6b1 55 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
DiegoOstuni 1:86504e1ac6b1 56 hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
DiegoOstuni 1:86504e1ac6b1 57 hspi1.Init.NSS = SPI_NSS_SOFT;
DiegoOstuni 1:86504e1ac6b1 58 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
DiegoOstuni 1:86504e1ac6b1 59 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
DiegoOstuni 1:86504e1ac6b1 60 hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
DiegoOstuni 1:86504e1ac6b1 61 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
DiegoOstuni 1:86504e1ac6b1 62 /* if (HAL_SPI_Init(&hspi1) != HAL_OK) {
DiegoOstuni 1:86504e1ac6b1 63 Error_Handler();
DiegoOstuni 1:86504e1ac6b1 64 }
DiegoOstuni 1:86504e1ac6b1 65 */
DiegoOstuni 1:86504e1ac6b1 66 }
DiegoOstuni 1:86504e1ac6b1 67