Prototype RF driver for STM Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo.

Prototype RF Driver for STM Sub-1 GHz RF Expansion Boards based on the SPSGRF-868 and SPSGRF-915 Modules for STM32 Nucleo

Currently supported boards:

Note, in order to use expansion board X-NUCLEO-IDS01A4 in mbed you need to perform the following HW modifications on the board:

  • Unmount resistor R4
  • Mount resistor R7

Furthermore, on some Nucleo development boards (e.g. the NUCLEO_F429ZI), in order to be able to use Ethernet together with these Sub-1 GHz RF expansion boards, you need to compile this driver with macro SPIRIT1_SPI_MOSI=PB_5 defined, while the development board typically requires some HW modification as e.g. described here!

This driver can be used together with the 6LoWPAN stack (a.k.a. Nanostack).

Files at this revision

API Documentation at this revision

Comitter:
Wolfgang Betz
Date:
Fri Oct 14 16:47:22 2016 +0200
Parent:
2:45642c5198a2
Child:
4:07537ca85c66
Commit message:
Switching radio on

Changed in this revision

SimpleSpirit1.cpp Show annotated file Show diff for this revision Revisions of this file
SimpleSpirit1.h Show annotated file Show diff for this revision Revisions of this file
libs/Contiki_STM32_Library/spirit1-arch.h Show diff for this revision Revisions of this file
libs/Contiki_STM32_Library/st-lib.h Show diff for this revision Revisions of this file
libs/spirit1/X-NUCLEO-IDS01Ax/radio_spi.h Show diff for this revision Revisions of this file
radio_spi.h Show annotated file Show diff for this revision Revisions of this file
--- a/SimpleSpirit1.cpp	Fri Oct 14 10:42:56 2016 +0200
+++ b/SimpleSpirit1.cpp	Fri Oct 14 16:47:22 2016 +0200
@@ -1,18 +1,48 @@
 /*** Mbed Includes ***/
 #include "SimpleSpirit1.h"
+#include "radio_spi.h"
 
 
 /*** Macros from Cube Implementation ***/
-#define CLEAR_TXBUF()           (spirit_txbuf[0] = 0)
-#define CLEAR_RXBUF()           (spirit_rxbuf[0] = 0)
+#define CLEAR_TXBUF()		(spirit_txbuf[0] = 0)
+#define CLEAR_RXBUF()		(spirit_rxbuf[0] = 0)
 /* transceiver state. */
 #define ON     0
 #define OFF    1
 
+#ifndef NDEBUG
+#include <stdio.h>
+#define PRINTF(...) printf(__VA_ARGS__)
+#else
+#define PRINTF(...)
+#endif
 
-SimpleSpirit1 *SimpleSpirit1::_singleton = NULL;
+#if NULLRDC_CONF_802154_AUTOACK
+#define ACK_LEN 3
+static int wants_an_ack = 0; /* The packet sent expects an ack */
+//#define ACKPRINTF printf
+#define ACKPRINTF(...)
+#endif /* NULLRDC_CONF_802154_AUTOACK */
+
+#define SPIRIT_GPIO_IRQ		(SPIRIT_GPIO_3)
+
+#define SPIRIT1_STATUS()	(arch_refresh_status() & SPIRIT1_STATE_STATEBITS)
+
+#define SABORT_WAIT_US		(400)
+
+#define BUSYWAIT_UNTIL(cond, millisecs)                                        					\
+  do {                                                                 					 		\
+    uint32_t start = _busywait_timer.read_ms();                         							\
+    while (!(cond) && ((((uint32_t)(_busywait_timer.read_ms())) - start) < (uint32_t)millisecs));	\
+  } while(0)
+
 
 /*** Class Implementation ***/
+/** Static Class Variables **/
+SimpleSpirit1 *SimpleSpirit1::_singleton = NULL;
+Timer SimpleSpirit1::_busywait_timer;
+
+/** Constructor **/
 SimpleSpirit1::SimpleSpirit1(PinName mosi, PinName miso, PinName sclk,
 			     PinName irq, PinName cs, PinName sdn,
 			     PinName led) :
@@ -20,10 +50,11 @@
     _irq(irq),
     _chip_select(cs),
     _shut_down(sdn),
-    _led(led),
-    _nr_of_irq_disables(0)
+    _led(led)
 {
-    /* reset irq disable counter & disable irq */
+    /* reset irq disable counter and irq callback & disable irq */
+	_nr_of_irq_disables = 0;
+	_current_irq_callback = NULL;
     disable_irq();
 
     /* unselect chip */
@@ -32,8 +63,18 @@
     /* configure spi */
     _spi.format(8, 0); /* 8-bit, mode = 0, [order = SPI_MSB] only available in mbed3 */
     _spi.frequency(5000000); // 5MHz
+
+    /* start timer */
+    _busywait_timer.start();
+
+    /* init cube vars */
+    spirit_on = OFF;
+    packet_is_prepared = 0;
+    receiving_packet = 0;
+    just_got_an_ack = 0;
 }
 
+/** Init Function **/
 void SimpleSpirit1::init() {
     /* set frequencies */
     radio_set_xtal_freq(XTAL_FREQUENCY);
@@ -109,3 +150,214 @@
     };
     spirit_gpio_init(&x_gpio_init);
 }
+
+/** Prepare the radio with a packet to be sent. **/
+int SimpleSpirit1::prepare(const void *payload, unsigned short payload_len) {
+	PRINTF("Spirit1: prep %u\n", payload_len);
+	packet_is_prepared = 0;
+
+	/* Checks if the payload length is supported */
+	if(payload_len > MAX_PACKET_LEN) {
+		return RADIO_TX_ERR;
+	}
+
+	/* Should we delay for an ack? */
+#if NULLRDC_CONF_802154_AUTOACK
+	frame802154_t info154;
+	wants_an_ack = 0;
+	if(payload_len > ACK_LEN
+			&& frame802154_parse((char*)payload, payload_len, &info154) != 0) {
+		if(info154.fcf.frame_type == FRAME802154_DATAFRAME
+				&& info154.fcf.ack_required != 0) {
+			wants_an_ack = 1;
+		}
+	}
+#endif /* NULLRDC_CONF_802154_AUTOACK */
+
+	/* Sets the length of the packet to send */
+	disable_irq();
+	cmd_strobe_command(SPIRIT1_STROBE_FTX);
+	pkt_basic_set_payload_length(payload_len);
+	spi_write_linear_fifo(payload_len, (uint8_t *)payload);
+	enable_irq();
+
+	PRINTF("PREPARE OUT\n");
+
+	packet_is_prepared = 1;
+	return RADIO_TX_OK;
+}
+
+/** Send the packet that has previously been prepared. **/
+int SimpleSpirit1::transmit(unsigned short payload_len) {
+	/* This function blocks until the packet has been transmitted */
+	//rtimer_clock_t rtimer_txdone, rtimer_rxack;
+
+	PRINTF("TRANSMIT IN\n");
+	if(!packet_is_prepared) {
+		return RADIO_TX_ERR;
+	}
+
+	/* Stores the length of the packet to send */
+	/* Others spirit_radio_prepare will be in hold */
+	spirit_txbuf[0] = payload_len;
+
+	/* Puts the SPIRIT1 in TX state */
+	receiving_packet = 0;
+	set_ready_state();
+	cmd_strobe_command(SPIRIT1_STROBE_TX);
+	just_got_an_ack = 0;
+	BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_TX, 1);
+	//BUSYWAIT_UNTIL(SPIRIT1_STATUS() != SPIRIT1_STATE_TX, 4); //For GFSK with high data rate
+	BUSYWAIT_UNTIL(SPIRIT1_STATUS() != SPIRIT1_STATE_TX, 50); //For FSK with low data rate
+
+	/* Reset radio - needed for immediate RX of ack */
+	CLEAR_TXBUF();
+	CLEAR_RXBUF();
+	disable_irq();
+	irq_clear_status();
+	cmd_strobe_command(SPIRIT1_STROBE_SABORT);
+	wait_us(SABORT_WAIT_US);
+	cmd_strobe_command(SPIRIT1_STROBE_READY);
+	BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_READY, 1);
+	cmd_strobe_command(SPIRIT1_STROBE_RX);
+	BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_RX, 1);
+	enable_irq();
+
+#if XXX_ACK_WORKAROUND
+	just_got_an_ack = 1;
+#endif /* XXX_ACK_WORKAROUND */
+
+#if NULLRDC_CONF_802154_AUTOACK
+	if (wants_an_ack) {
+		rtimer_txdone = _busywait_timer.read_ms();
+		BUSYWAIT_UNTIL(just_got_an_ack, 2);
+		rtimer_rxack = _busywait_timer.read_ms();
+
+		if(just_got_an_ack) {
+			ACKPRINTF("debug_ack: ack received after %u ms\n",
+					(uint32_t)(rtimer_rxack - rtimer_txdone));
+		} else {
+			ACKPRINTF("debug_ack: no ack received\n");
+		}
+	}
+#endif /* NULLRDC_CONF_802154_AUTOACK */
+
+	PRINTF("TRANSMIT OUT\n");
+
+	CLEAR_TXBUF();
+
+	packet_is_prepared = 0;
+
+	wait_us(1);
+
+	return RADIO_TX_OK;
+}
+
+/** Set Ready State **/
+void SimpleSpirit1::set_ready_state(void) {
+  PRINTF("READY IN\n");
+
+  irq_clear_status();
+  disable_irq();
+
+  if(SPIRIT1_STATUS() == SPIRIT1_STATE_STANDBY) {
+	  cmd_strobe_command(SPIRIT1_STROBE_READY);
+  } else if(SPIRIT1_STATUS() == SPIRIT1_STATE_RX) {
+	  cmd_strobe_command(SPIRIT1_STROBE_SABORT);
+	  irq_clear_status();
+  }
+
+  enable_irq();
+
+  PRINTF("READY OUT\n");
+}
+
+int SimpleSpirit1::radio_off(void) {
+  PRINTF("Spirit1: ->off\n");
+  if(spirit_on == ON) {
+    /* Disables the mcu to get IRQ from the SPIRIT1 */
+    disable_irq();
+
+    /* first stop rx/tx */
+    cmd_strobe_command(SPIRIT1_STROBE_SABORT);
+
+    /* Clear any pending irqs */
+    irq_clear_status();
+
+    BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_READY, 5);
+    if(SPIRIT1_STATUS() != SPIRIT1_STATE_READY) {
+      PRINTF("Spirit1: failed off->ready\n");
+      return 1;
+    }
+
+    /* Puts the SPIRIT1 in STANDBY */
+    cmd_strobe_command(SPIRIT1_STROBE_STANDBY);
+    BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_STANDBY, 5);
+    if(SPIRIT1_STATUS() != SPIRIT1_STATE_STANDBY) {
+      PRINTF("Spirit1: failed off->standby\n");
+      return 1;
+    }
+
+    spirit_on = OFF;
+    CLEAR_TXBUF();
+    CLEAR_RXBUF();
+  }
+  PRINTF("Spirit1: off.\n");
+  return 0;
+}
+
+int SimpleSpirit1::radio_on(void) {
+  PRINTF("Spirit1: on\n");
+  cmd_strobe_command(SPIRIT1_STROBE_SABORT);
+  wait_us(SABORT_WAIT_US);
+  if(spirit_on == OFF) {
+    /* ensure we are in READY state as we go from there to Rx */
+    cmd_strobe_command(SPIRIT1_STROBE_READY);
+    BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_READY, 5);
+    if(SPIRIT1_STATUS() != SPIRIT1_STATE_READY) {
+      PRINTF("Spirit1: failed to turn on\n");
+	  while(1);
+      //return 1;
+    }
+
+    /* now we go to Rx */
+    cmd_strobe_command(SPIRIT1_STROBE_RX);
+    BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_RX, 5);
+    if(SPIRIT1_STATUS() != SPIRIT1_STATE_RX) {
+      PRINTF("Spirit1: failed to enter rx\n");
+	  while(1);
+      //return 1;
+    }
+
+    /* Enables the mcu to get IRQ from the SPIRIT1 */
+    spirit_on = ON;
+    if((_current_irq_callback != NULL) && (*_current_irq_callback)) {
+    	enable_irq();
+    }
+  }
+
+  return 0;
+}
+
+uint16_t SimpleSpirit1::arch_refresh_status(void) {
+  uint16_t mcstate;
+  uint8_t header[2];
+  header[0]=READ_HEADER;
+  header[1]=MC_STATE1_BASE;
+
+  /* Puts the SPI chip select low to start the transaction */
+  chip_sync_select();
+
+  /* Write the aHeader bytes and read the SPIRIT1 status bytes */
+  mcstate = _spi.write(header[0]);
+  mcstate = mcstate<<8;
+
+  /* Write the aHeader bytes and read the SPIRIT1 status bytes */
+  mcstate |= _spi.write(header[1]);
+
+  /* Puts the SPI chip select high to end the transaction */
+  chip_sync_unselect();
+
+  return mcstate;
+}
+
--- a/SimpleSpirit1.h	Fri Oct 14 10:42:56 2016 +0200
+++ b/SimpleSpirit1.h	Fri Oct 14 16:47:22 2016 +0200
@@ -11,7 +11,6 @@
 
 /*** Contiki Lib Includes ***/
 #include "spirit1.h"
-#include "st-lib.h"
 #include "spirit1-config.h"
 #include "spirit1-const.h"
 
@@ -41,6 +40,9 @@
     DigitalOut _shut_down; // PA_10 (D2) ('1' == shut_down)
     DigitalOut _led; // PB_4 (D5) (optional)
 
+    static Timer _busywait_timer;
+    Callback<void()> *_current_irq_callback;
+
     /** Static Variables from Cube Implementation **/
     /*
      * The buffers which hold incoming data.
@@ -50,14 +52,14 @@
     uint8_t spirit_rxbuf[MAX_PACKET_LEN+1];
     uint8_t spirit_txbuf[MAX_PACKET_LEN+1-SPIRIT_MAX_FIFO_LEN];
     volatile unsigned int spirit_on;
-
+    volatile uint8_t receiving_packet;
+    int packet_is_prepared;
+    int just_got_an_ack;
 
     /** Low Level Instance Variables **/
     unsigned int _nr_of_irq_disables;
 
-    /** Low Level Ins
-    	return *_singleton;
-     * tance Methods **/
+    /** Low Level Instance Methods **/
     void disable_irq(void) {
     	_irq.disable_irq();
     	_nr_of_irq_disables++;
@@ -83,6 +85,25 @@
     	wait_us(1); // heuristic value
     }
 
+    /**
+     * @brief      Write and read a buffer to/from the SPI peripheral device at the same time
+     *             in 8-bit data mode using synchronous SPI communication.
+     * @param[in]  pBufferToWrite pointer to the buffer of data to send.
+     * @param[out] pBufferToRead pointer to the buffer to read data into.
+     * @param[in]  NumBytes number of bytes to read and write.
+     * @retval     0 if ok.
+     * @retval     -1 if data format error.
+     * @note       When using the SPI in Interrupt-mode, remember to disable interrupts
+     *             before calling this function and to enable them again after.
+     */
+    void spi_write_read(uint8_t* pBufferToWrite, uint8_t* pBufferToRead, uint16_t NumBytes)
+    {
+        /* Read and write data at the same time. */
+    	for (int i = 0; i < NumBytes; i++) {
+            pBufferToRead[i] = _spi.write(pBufferToWrite[i]);
+    	}
+    }
+
     /** Radio Instance Methods **/
     void radio_set_xtal_freq(uint32_t freq) {
     	SpiritRadioSetXtalFrequency(freq);
@@ -99,7 +120,7 @@
     uint8_t radio_init(SRadioInit *init_struct) {
     	return SpiritRadioInit(init_struct);
     }
-    
+
     void radio_persisten_rx(SpiritFunctionalState xNewState) {
     	SpiritRadioPersistenRx(xNewState);
     }
@@ -113,7 +134,11 @@
     	SpiritPktBasicInit(pxPktBasicInit);
     }
 
-    /** IRQ Instance Methods **/
+    void pkt_basic_set_payload_length(uint16_t nPayloadLength) {
+    	SpiritPktBasicSetPayloadLength(nPayloadLength);
+    }
+
+	/** IRQ Instance Methods **/
     void irq_de_init(SpiritIrqs* pxIrqInit) {
     	SpiritIrqDeInit(pxIrqInit);
     }
@@ -167,6 +192,15 @@
     	SpiritCmdStrobeCommand((SpiritCmd)cmd);
     }
 
+    /** SPI Instance Methods **/
+    StatusBytes spi_write_linear_fifo(uint8_t cNbBytes, uint8_t* pcBuffer) {
+    	return SdkEvalSpiWriteFifo(cNbBytes, pcBuffer);
+    }
+
+    /** Internal Spirit Methods */
+    void set_ready_state(void);
+    uint16_t arch_refresh_status(void);
+
     /** Friend Functions **/
     friend StatusBytes SdkEvalSpiWriteRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer);
     friend StatusBytes SdkEvalSpiReadRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer);
@@ -230,13 +264,22 @@
 
     /** Attach a function to be called when a SPI interrupt occurs
      *
-     *  @param func A pointer to a void function, or 0 to set as none
+     *  @param func A void() callback, or 0 to set as none
      *
      *  @note  Function 'func' will be executed in interrupt context!
-     *  @note  This function enables the SPI interrupt!
      */
-    void attach_irq(Callback<void()> &func) {
+    void attach_irq(Callback<void()> func) {
     	_irq.fall(func);
-    	enable_irq();
+    	_current_irq_callback = &func;
     }
+
+    /** Prepare the radio with a packet to be sent. */
+    int prepare(const void *payload, unsigned short payload_len);
+
+    /** Send the packet that has previously been prepared. */
+    int transmit(unsigned short payload_len);
+
+    /** Switch Radio On/Off **/
+    int radio_on(void);
+    int radio_off(void);
 };
--- a/libs/Contiki_STM32_Library/spirit1-arch.h	Fri Oct 14 10:42:56 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2012, STMicroelectronics.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- */
-/*---------------------------------------------------------------------------*/
-#ifndef __SPIRIT1_ARCH_H__
-#define __SPIRIT1_ARCH_H__
-/*---------------------------------------------------------------------------*/
-#include "string.h"
-#include "SPIRIT_Management.h"
-#include "radio_gpio.h"
-#include "radio_spi.h"
-#include "st-lib.h"
-/*---------------------------------------------------------------------------*/
-#define IRQ_ENABLE()             st_lib_radio_gpio_interrupt_cmd(RADIO_GPIO_IRQ,0x0F,0x0F,ENABLE);
-#define IRQ_DISABLE()            st_lib_radio_gpio_interrupt_cmd(RADIO_GPIO_IRQ,0x0F,0x0F,DISABLE); 
-#define spirit_spi_busy()        (!(RADIO_SPI_CS_PORT->IDR & RADIO_SPI_CS_PIN))
-#define SPIRIT1_STATUS()       (spirit1_arch_refresh_status() & SPIRIT1_STATE_STATEBITS)
-/*---------------------------------------------------------------------------*/
-uint16_t spirit1_arch_refresh_status(void);
-/*---------------------------------------------------------------------------*/
-#endif /* __SPIRIT1_ARCH_H__ */
--- a/libs/Contiki_STM32_Library/st-lib.h	Fri Oct 14 10:42:56 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,416 +0,0 @@
-/**
-******************************************************************************
-* @file    st-lib.h
-* @author  System LAB
-* @version V1.0.0
-* @date    30-July-2015
-* @brief   Contiki style wrapping library for STM32Cube HAL APIs 
-******************************************************************************
-* @attention
-*
-* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
-*
-* Redistribution and use in source and binary forms, with or without modification,
-* are permitted provided that the following conditions are met:
-*   1. Redistributions of source code must retain the above copyright notice,
-*      this list of conditions and the following disclaimer.
-*   2. Redistributions in binary form must reproduce the above copyright notice,
-*      this list of conditions and the following disclaimer in the documentation
-*      and/or other materials provided with the distribution.
-*   3. Neither the name of STMicroelectronics nor the names of its contributors
-*      may be used to endorse or promote products derived from this software
-*      without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-******************************************************************************
-*/
-/*---------------------------------------------------------------------------*/
-/**
- * \defgroup stm32nucleo-spirit1  STM32Cube HAL APIs
- *
- * Abstraction of STM32Cube HAL APIs as per Contiki coding rules
- * @{
- *
- * \file
- * Header file for the STM32Cube HAL APIs
- */
-/*---------------------------------------------------------------------------*/
-#ifndef ST_LIB_H_
-#define ST_LIB_H_
-
-/*---------------------------------------------------------------------------*/
-/* extern global varialbles */
-#ifdef USE_X_CUBE_IDW01M1
-#define st_lib_uart_handle                       UartMsgHandle
-#else
-#define st_lib_uart_handle                       UartHandle
-#endif
-
-
-#define st_lib_g_x_status                        g_xStatus
-
-#define st_lib_p_spi_handle                      pSpiHandle
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* misc */
-#define st_lib_tim2_irq_handler(...)                      TIM2_IRQHandler(__VA_ARGS__)
-#define st_lib_tim5_irq_handler(...)                      TIM5_IRQHandler(__VA_ARGS__)
-#define st_lib_spirit_management_set_frequency_base(...)  SpiritManagementSetFrequencyBase(__VA_ARGS__)
-#define st_lib_sys_tick_handler(...)                      SysTick_Handler(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* MCU_Interface.h */
-#include "MCU_Interface.h"
-
-#define st_lib_spirit_spi_init(...)              SpiritSpiInit(__VA_ARGS__)
-#define st_lib_spirit_spi_read_linear_fifo(...)  SpiritSpiReadLinearFifo(__VA_ARGS__)
-#define st_lib_spirit_spi_write_linear_fifo(...) SpiritSpiWriteLinearFifo(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-
-/*---------------------------------------------------------------------------*/
-/* radio_gpio.h */
-#include "radio_gpio.h"
-
-#define st_lib_radio_gpio_interrupt_cmd(...)     RadioGpioInterruptCmd(__VA_ARGS__)
-#define st_lib_radio_gpio_init(...)              RadioGpioInit(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* radio_shield_config.h */
-#include "radio_shield_config.h"
-
-#define st_lib_a_led_gpio_port                   aLED_GPIO_PORT
-#define st_lib_a_led_gpio_pin                    aLED_GPIO_PIN
-
-#define st_lib_radio_shield_led_init(...)        RadioShieldLedInit(__VA_ARGS__)
-#define st_lib_radio_shield_led_off(...)         RadioShieldLedOff(__VA_ARGS__)
-#define st_lib_radio_shield_led_on(...)          RadioShieldLedOn(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* radio_spi.h */
-#include "radio_spi.h"
-
-#define st_lib_radio_spi_cs_high(...)            RadioSpiCSHigh(__VA_ARGS__)
-#define st_lib_radio_spi_cs_low(...)             RadioSpiCSLow(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_Commands.h */
-#include "SPIRIT_Commands.h"
-
-#define st_lib_spirit_cmd_strobe_flush_rx_fifo(...) SpiritCmdStrobeFlushRxFifo(__VA_ARGS__)
-#define st_lib_spirit_cmd_strobe_command(...)       SpiritCmdStrobeCommand(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_Gpio.h */
-#include "SPIRIT_Gpio.h"
-
-#define st_lib_s_gpio_init                       SGpioInit
-
-#define st_lib_spirit_gpio_init(...)             SpiritGpioInit(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_Irq.h */
-#include "SPIRIT_Irq.h"
-
-#define st_lib_spirit_irqs                       SpiritIrqs
-
-#define st_lib_spirit_irq(...)                   SpiritIrq(__VA_ARGS__)
-#define st_lib_spirit_irq_de_init(...)           SpiritIrqDeInit(__VA_ARGS__)
-#define st_lib_spirit_irq_init(...)              SpiritIrqInit(__VA_ARGS__)
-#define st_lib_spirit_irq_get_mask(...)          SpiritIrqGetMask(__VA_ARGS__)
-#define st_lib_spirit_irq_get_status(...)        SpiritIrqGetStatus(__VA_ARGS__)
-#define st_lib_spirit_irq_clear_status(...)      SpiritIrqClearStatus(__VA_ARGS__)
-#define st_lib_spirit_irq_chack_flag(...)        SpiritIrqCheckFlag(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_LinearFifo.h */
-#include "SPIRIT_LinearFifo.h"
-
-#define st_lib_spirit_linear_fifo_read_num_elements_rx_fifo(...) SpiritLinearFifoReadNumElementsRxFifo(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_PktBasic.h */
-#include "SPIRIT_PktBasic.h"
-
-#define st_lib_pkt_basic_init                                PktBasicInit
-
-#define st_lib_spirit_pkt_basic_init(...)                    SpiritPktBasicInit(__VA_ARGS__)
-#define st_lib_spirit_pkt_basic_get_received_pkt_length(...) SpiritPktBasicGetReceivedPktLength(__VA_ARGS__)
-#define st_lib_spirit_pkt_basic_set_payload_length(...)      SpiritPktBasicSetPayloadLength(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_Qi.h */
-#include "SPIRIT_Qi.h"
-
-#define st_lib_spirit_qi_get_rssi_dbm(...)           SpiritQiGetRssidBm(__VA_ARGS__)
-#define st_lib_spirit_qi_pqi_check(...)              SpiritQiPqiCheck(__VA_ARGS__)
-#define st_lib_spirit_qi_sqi_check(...)              SpiritQiSqiCheck(__VA_ARGS__)
-#define st_lib_spirit_qi_set_pqi_threshold(...)      SpiritQiSetPqiThreshold(__VA_ARGS__)
-#define st_lib_spirit_qi_get_pqi_threshold(...)      SpiritQiGetPqiThreshold(__VA_ARGS__)
-#define st_lib_spirit_qi_set_sqi_threshold(...)      SpiritQiSetSqiThreshold(__VA_ARGS__)
-#define st_lib_spirit_qi_get_sqi_threshold(...)      SpiritQiGetSqiThreshold(__VA_ARGS__)
-#define st_lib_spirit_qi_set_rssi_threshold(...)     SpiritQiSetRssiThreshold(__VA_ARGS__)
-#define st_lib_spirit_qi_get_rssi_threshold(...)     SpiritQiGetRssiThreshold(__VA_ARGS__)
-#define st_lib_spirit_qi_compute_rssi_threshold(...) SpiritQiComputeRssiThreshold(__VA_ARGS__)
-#define st_lib_spirit_qi_set_rssi_threshold_dbm(...) SpiritQiSetRssiThresholddBm(__VA_ARGS__)
-#define st_lib_spirit_qi_get_pqi(...)                SpiritQiGetPqi(__VA_ARGS__)
-#define st_lib_spirit_qi_get_sqi(...)                SpiritQiGetSqi(__VA_ARGS__)
-#define st_lib_spirit_qi_get_lqi(...)                SpiritQiGetLqi(__VA_ARGS__)
-#define st_lib_spirit_qi_get_cs(...)                 SpiritQiGetCs(__VA_ARGS__)
-#define st_lib_spirit_qi_get_rssi(...)               SpiritQiGetRssi(__VA_ARGS__)
-#define st_lib_spirit_qi_set_rssi_filter_gain(...)   SpiritQiSetRssiFilterGain(__VA_ARGS__)
-#define st_lib_spirit_qi_get_rssi_filter_gain(...)   SpiritQiGetRssiFilterGain(__VA_ARGS__)
-#define st_lib_spirit_qi_set_cs_mode(...)            SpiritQiSetCsMode(__VA_ARGS__)
-#define st_lib_spirit_qi_get_cs_mode(...)            SpiritQiGetCsMode(__VA_ARGS__)
-#define st_lib_spirit_qi_cs_timeout_mask(...)        SpiritQiCsTimeoutMask(__VA_ARGS__)
-#define st_lib_spirit_qi_pqi_timeout_mask(...)       SpiritQiPqiTimeoutMask(__VA_ARGS__)
-#define st_lib_spirit_qi_sqi_timeout_mask(...)       SpiritQiSqiTimeoutMask(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_Radio.h */
-#include "SPIRIT_Radio.h"
-
-#define st_lib_s_radio_init                             SRadioInit
-
-#define st_lib_spirit_radio_afc_freeze_on_sync(...)     SpiritRadioAFCFreezeOnSync(__VA_ARGS__)
-#define st_lib_spirit_radio_init(...)                   SpiritRadioInit(__VA_ARGS__)
-#define st_lib_spirit_radio_persisten_rx(...)           SpiritRadioPersistenRx(__VA_ARGS__)
-#define st_lib_spirit_radio_set_pa_level_dbm(...)       SpiritRadioSetPALeveldBm(__VA_ARGS__)
-#define st_lib_spirit_radio_set_pa_level_max_index(...) SpiritRadioSetPALevelMaxIndex(__VA_ARGS__)
-#define st_lib_spirit_radio_set_xtal_frequency(...)     SpiritRadioSetXtalFrequency(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_Timer.h */
-#include "SPIRIT_Timer.h"
-
-#define st_lib_spirit_timer_set_rx_timeout_stop_condition(...)  SpiritTimerSetRxTimeoutStopCondition(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* SPIRIT_Types.h */
-#include "SPIRIT_Types.h"
-
-#define st_lib_spirit_bool                       SpiritBool
-#define st_lib_spirit_status                     SpiritStatus
-#define st_lib_spirit_flag_status                SpiritFlagStatus
-
-#define st_lib_spirit_refresh_status(...)        SpiritRefreshStatus(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* stm32l152xe.h */
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l152xe.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f401xe.h"
-#endif
-
-#define st_lib_irq_n_type                        IRQn_Type
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* stm32l1xx.h */
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l1xx.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f4xx.h"
-#endif
-
-#define st_lib_flag_status                       FlagStatus
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* stm32l1xx_hal_cortex.h */
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l1xx_hal_cortex.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f4xx_hal_cortex.h"
-#endif
-
-#define st_lib_hal_nvic_enable_irq(...)           HAL_NVIC_EnableIRQ(__VA_ARGS__)
-#define st_lib_hal_nvic_set_priority(...)         HAL_NVIC_SetPriority(__VA_ARGS__)
-#define st_lib_hal_systick_clk_source_config(...) HAL_SYSTICK_CLKSourceConfig(__VA_ARGS__)
-#define st_lib_hal_systick_config(...)            HAL_SYSTICK_Config(__VA_ARGS__)
-
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* stm32l1xx_hal_rcc.h */
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l1xx_hal_rcc.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f4xx_hal_rcc.h"
-#endif
-
-
-#define st_lib_tim2_clk_enable(...)              __TIM2_CLK_ENABLE(__VA_ARGS__)
-#define st_lib_tim5_clk_enable(...)              __TIM5_CLK_ENABLE(__VA_ARGS__)
-
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* stm32l1xx_hal_spi.h */
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l1xx_hal_spi.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f4xx_hal_spi.h"
-#endif
-
-#define st_lib_spi_handle_typedef                SPI_HandleTypeDef
-
-#define st_lib_hal_spi_get_flag(...)             __HAL_SPI_GET_FLAG(__VA_ARGS__)
-#define st_lib_hal_spi_transmit_receive(...)     HAL_SPI_TransmitReceive(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* stm32l1xx_hal_tim.h */
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l1xx_hal_tim.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f4xx_hal_tim.h"
-#endif
-
-#define st_lib_tim_handle_typedef                TIM_HandleTypeDef
-#define st_lib_tim_clock_config_typedef          TIM_ClockConfigTypeDef
-#define st_lib_tim_oc_init_typedef               TIM_OC_InitTypeDef
-
-#define st_lib_hal_tim_base_init(...)            HAL_TIM_Base_Init(__VA_ARGS__)
-#define st_lib_hal_tim_base_start_it(...)        HAL_TIM_Base_Start_IT(__VA_ARGS__)
-#define st_lib_hal_tim_config_clock_source(...)  HAL_TIM_ConfigClockSource(__VA_ARGS__)
-#define st_lib_hal_tim_clear_flag(...)           __HAL_TIM_CLEAR_FLAG(__VA_ARGS__)
-#define st_lib_hal_tim_clear_it(...)             __HAL_TIM_CLEAR_IT(__VA_ARGS__)
-#define st_lib_hal_tim_enable(...)               __HAL_TIM_ENABLE(__VA_ARGS__)
-#define st_lib_hal_tim_enable_it(...)            __HAL_TIM_ENABLE_IT(__VA_ARGS__)
-#define st_lib_hal_tim_oc_init(...)              HAL_TIM_OC_Init(__VA_ARGS__)
-#define st_lib_hal_tim_oc_config_channel(...)    HAL_TIM_OC_ConfigChannel(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-
-/*---------------------------------------------------------------------------*/
-/* stm32l1xx_hal_uart.h */
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l1xx_hal_uart.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f4xx_hal_uart.h"
-#endif
-
-#define st_lib_uart_handle_typedef               UART_HandleTypeDef
-
-#define st_lib_hal_uart_enable_it(...)           __HAL_UART_ENABLE_IT(__VA_ARGS__)
-#define st_lib_hal_uart_init(...)                HAL_UART_Init(__VA_ARGS__)
-#define st_lib_hal_uart_receive(...)             HAL_UART_Receive(__VA_ARGS__)
-#define st_lib_hal_uart_receive_it(...)          HAL_UART_Receive_IT(__VA_ARGS__)
-#define st_lib_hal_uart_rx_cplt_callback(...)    HAL_UART_RxCpltCallback(__VA_ARGS__)
-#define st_lib_hal_uart_transmit(...)            HAL_UART_Transmit(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-#if 0 // betzw
-/*---------------------------------------------------------------------------*/
-/* stm32l1xx_nucleo.h */
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l1xx_nucleo.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f4xx_nucleo.h"
-#endif
-
-#define st_lib_gpio_typedef                      GPIO_TypeDef
-#define st_lib_gpio_port                         GPIO_PORT
-#define st_lib_gpio_pin                          GPIO_PIN
-
-#define st_lib_bsp_led_init(...)                 BSP_LED_Init(__VA_ARGS__)
-#define st_lib_bsp_led_off(...)                  BSP_LED_Off(__VA_ARGS__)
-#define st_lib_bsp_led_on(...)                   BSP_LED_On(__VA_ARGS__)
-#define st_lib_bsp_pb_init(...)                  BSP_PB_Init(__VA_ARGS__)
-#define st_lib_bsp_pb_get_state(...)             BSP_PB_GetState(__VA_ARGS__)
-#define st_lib_hal_gpio_read_pin(...)            HAL_GPIO_ReadPin(__VA_ARGS__)
-#define st_lib_hal_gpio_write_pin(...)           HAL_GPIO_WritePin(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-#endif // 0
-
-#if COMPILE_SENSORS
-/*---------------------------------------------------------------------------*/
-/* x_nucleo_iks01a1.h */
-#include "x_nucleo_iks01a1.h"
-
-#define st_lib_axes_raw_typedef                  AxesRaw_TypeDef
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* x_nucleo_iks01a1_hum_temp.h */
-#include "x_nucleo_iks01a1_hum_temp.h"
-
-#define st_lib_bsp_hum_temp_is_initialized(...)  BSP_HUM_TEMP_isInitialized(__VA_ARGS__)
-#define st_lib_bsp_hum_temp_init(...)            BSP_HUM_TEMP_Init(__VA_ARGS__)
-#define st_lib_bsp_hum_temp_get_humidity(...)    BSP_HUM_TEMP_GetHumidity(__VA_ARGS__)
-#define st_lib_bsp_hum_temp_get_temperature(...) BSP_HUM_TEMP_GetTemperature(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* x_nucleo_iks01a1_imu_6axes.h */
-#include "x_nucleo_iks01a1_imu_6axes.h"
-
-#define st_lib_bsp_imu_6axes_is_initialized(...) BSP_IMU_6AXES_isInitialized(__VA_ARGS__)
-#define st_lib_bsp_imu_6axes_init(...)           BSP_IMU_6AXES_Init(__VA_ARGS__)
-#define st_lib_bsp_imu_6axes_g_get_axes_raw(...) BSP_IMU_6AXES_G_GetAxesRaw(__VA_ARGS__)
-#define st_lib_bsp_imu_6axes_x_get_axes_raw(...) BSP_IMU_6AXES_X_GetAxesRaw(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* x_nucleo_iks01a1_magneto.h */
-#include "x_nucleo_iks01a1_magneto.h"
-
-#define st_lib_bsp_magneto_m_get_axes_raw(...)   BSP_MAGNETO_M_GetAxesRaw(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* x_nucleo_iks01a1_pressure.h */
-#include "x_nucleo_iks01a1_pressure.h"
-
-#define st_lib_bsp_pressure_init(...)            BSP_PRESSURE_Init(__VA_ARGS__)
-#define st_lib_bsp_pressure_get_pressure(...)    BSP_PRESSURE_GetPressure(__VA_ARGS__)
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-#endif /*COMPILE_SENSORS*/
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-#endif /*ST_LIB_H_*/
-/*---------------------------------------------------------------------------*/
-/** @} */
--- a/libs/spirit1/X-NUCLEO-IDS01Ax/radio_spi.h	Fri Oct 14 10:42:56 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-/**
-******************************************************************************
-* @file    radio_spi.h
-* @author  System Lab - NOIDA
-* @version V1.0.0
-* @date    15-May-2014
-* @brief   This file contains all the functions prototypes for SPI .
-******************************************************************************
-* @attention
-*
-* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
-*
-* Redistribution and use in source and binary forms, with or without modification,
-* are permitted provided that the following conditions are met:
-*   1. Redistributions of source code must retain the above copyright notice,
-*      this list of conditions and the following disclaimer.
-*   2. Redistributions in binary form must reproduce the above copyright notice,
-*      this list of conditions and the following disclaimer in the documentation
-*      and/or other materials provided with the distribution.
-*   3. Neither the name of STMicroelectronics nor the names of its contributors
-*      may be used to endorse or promote products derived from this software
-*      without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-******************************************************************************
-*/
-
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __RADIO_SPI_H
-#define __RADIO_SPI_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-  
-/* Includes ------------------------------------------------------------------*/
-#ifdef USE_STM32L1XX_NUCLEO
-#include "stm32l1xx_hal.h"
-#endif
-
-#ifdef USE_STM32F4XX_NUCLEO
-#include "stm32f4xx_hal.h"
-#endif
-#include "SPIRIT_Config.h"
-#include "radio_spi.h" 
-#include "spirit1-arch.h"
-/**
- * @addtogroup BSP
- * @{
- */ 
-  
-/* Exported types ------------------------------------------------------------*/
-
-  
-/* Exported constants --------------------------------------------------------*/
-  
-  
-/* Exported macro ------------------------------------------------------------*/
-  /* Define for SPIRIT1 board  */  
- #if !defined (USE_SPIRIT1_DEFAULT)
- #define USE_SPIRIT1_DEFAULT
-#endif
-  
-/* SPIRIT1_Spi_config */ 
-/* SPI1 */  
-#define RADIO_SPI                                 SPI1
-#define RADIO_SPI_CLK_ENABLE()                  __SPI1_CLK_ENABLE()
-#define RADIO_SPI_CLK_DISABLE()                 __SPI1_CLK_DISABLE()
-
-#define RADIO_SPI_MISO_PORT                      GPIOA
-#define RADIO_SPI_MISO_PIN                       GPIO_PIN_6
-#define RADIO_SPI_MISO_CLOCK_ENABLE()            __GPIOA_CLK_ENABLE()
-#define RADIO_SPI_MISO_CLOCK_DISABLE()           __GPIOA_CLK_DISABLE() 
-  
-#define RADIO_SPI_MOSI_PORT                      GPIOA
-#define RADIO_SPI_MOSI_PIN                       GPIO_PIN_7
-#define RADIO_SPI_MOSI_CLOCK_ENABLE()            __GPIOA_CLK_ENABLE()
-#define RADIO_SPI_MOSI_CLOCK_DISABLE()           __GPIOA_CLK_DISABLE()   
-  
- 
- 
-#ifdef USE_SPIRIT1_DEFAULT    
-
-#define RADIO_SPI_SCK_PORT                      GPIOB
-#define RADIO_SPI_SCK_PIN                       GPIO_PIN_3
-#define RADIO_SPI_SCK_CLOCK_ENABLE()            __GPIOB_CLK_ENABLE()
-#define RADIO_SPI_SCK_CLOCK_DISABLE()           __GPIOB_CLK_DISABLE()
-
-  
-#define RADIO_SPI_CS_PORT                        GPIOB
-#define RADIO_SPI_CS_PIN                         GPIO_PIN_6
-#define RADIO_SPI_CS_CLOCK_ENABLE()            __GPIOB_CLK_ENABLE()
-#define RADIO_SPI_CS_CLOCK_DISABLE()           __GPIOB_CLK_DISABLE()
- 
-#else 
- 
-#define RADIO_SPI_SCK_PORT                      GPIOB
-#define RADIO_SPI_SCK_PIN                       GPIO_PIN_3
-#define RADIO_SPI_SCK_CLOCK_ENABLE()            __GPIOB_CLK_ENABLE()
-#define RADIO_SPI_SCK_CLOCK_DISABLE()           __GPIOB_CLK_DISABLE()
-
-  
-#define RADIO_SPI_CS_PORT                        GPIOB
-#define RADIO_SPI_CS_PIN                         GPIO_PIN_6
-#define RADIO_SPI_CS_CLOCK_ENABLE()            __GPIOB_CLK_ENABLE()
-#define RADIO_SPI_CS_CLOCK_DISABLE()           __GPIOB_CLK_DISABLE()
-    
-#endif  
-  
-/* Maximum Timeout values for flags waiting loops. These timeouts are not based
-   on accurate values, they just guarantee that the application will not remain
-   stuck if the SPI communication is corrupted.
-   You may modify these timeout values depending on CPU frequency and application
-   conditions (interrupts routines ...) */    
-#define RADIO_SPI_TIMEOUT_MAX                   ((uint32_t)1000)
-
-/* SPIRIT1_Spi_config_Private_Defines */  
-#define CS_TO_SCLK_DELAY     0x0200//FIXME what is this doing?
-#define CLK_TO_CS_DELAY      0x0001
-  
-/* SPIRIT1_Spi_config_Headers */
-#define HEADER_WRITE_MASK     0x00                                /*!< Write mask for header byte*/
-#define HEADER_READ_MASK      0x01                                /*!< Read mask for header byte*/
-#define HEADER_ADDRESS_MASK   0x00                                /*!< Address mask for header byte*/
-#define HEADER_COMMAND_MASK   0x80                                /*!< Command mask for header byte*/
-  
-#define LINEAR_FIFO_ADDRESS 0xFF                                  /*!< Linear FIFO address*/
-  
-/* SPIRIT1_Spi_config_Private_FunctionPrototypes */
-#define SPI_ENTER_CRITICAL()         IRQ_DISABLE()
-#define SPI_EXIT_CRITICAL()          IRQ_ENABLE()
-  
-/* SPIRIT1_Spi_config_Private_Functions */
-#define RadioSpiCSLow()        HAL_GPIO_WritePin(RADIO_SPI_CS_PORT, RADIO_SPI_CS_PIN, GPIO_PIN_RESET)
-#define RadioSpiCSHigh()       HAL_GPIO_WritePin(RADIO_SPI_CS_PORT, RADIO_SPI_CS_PIN, GPIO_PIN_SET)
-  
-/* SPIRIT1_Spi_config_Private_Macros */
-#define BUILT_HEADER(add_comm, w_r) (add_comm | w_r)                             /*!< macro to build the header byte*/
-#define WRITE_HEADER        BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_WRITE_MASK) /*!< macro to build the write 
-                                                                                                         header byte*/
-#define READ_HEADER         BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_READ_MASK)  /*!< macro to build the read 
-                                                                                                         header byte*/
-#define COMMAND_HEADER      BUILT_HEADER(HEADER_COMMAND_MASK, HEADER_WRITE_MASK) /*!< macro to build the command 
-                                                                                                         header byte*/
-  
-  
-  
-/* Exported Variables --------------------------------------------------------*/
-  
-  
-/* Exported functions ------------------------------------------------------- */ 
-void SdkEvalSpiInit(void);
-void SpiCSGpioSetLevel(GPIO_PinState xState);
-StatusBytes SdkEvalSpiWriteRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer);
-StatusBytes SdkEvalSpiReadRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer);
-StatusBytes SdkEvalSpiCommandStrobes(uint8_t cCommandCode);
-StatusBytes SdkEvalSpiWriteFifo(uint8_t cNbBytes, uint8_t* pcBuffer);
-StatusBytes SdkEvalSpiReadFifo(uint8_t cNbBytes, uint8_t* pcBuffer);
-
-  
-#ifdef __cplusplus
-}
-#endif
-#endif /*__RADIO_SPI_H */
-
-/**
-* @}
-*/
-
-/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/radio_spi.h	Fri Oct 14 16:47:22 2016 +0200
@@ -0,0 +1,185 @@
+/**
+******************************************************************************
+* @file    radio_spi.h
+* @author  System Lab - NOIDA
+* @version V1.0.0
+* @date    15-May-2014
+* @brief   This file contains all the functions prototypes for SPI .
+******************************************************************************
+* @attention
+*
+* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*   1. Redistributions of source code must retain the above copyright notice,
+*      this list of conditions and the following disclaimer.
+*   2. Redistributions in binary form must reproduce the above copyright notice,
+*      this list of conditions and the following disclaimer in the documentation
+*      and/or other materials provided with the distribution.
+*   3. Neither the name of STMicroelectronics nor the names of its contributors
+*      may be used to endorse or promote products derived from this software
+*      without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+******************************************************************************
+*/
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __RADIO_SPI_H
+#define __RADIO_SPI_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+  
+/* Includes ------------------------------------------------------------------*/
+#ifdef USE_STM32L1XX_NUCLEO
+#include "stm32l1xx_hal.h"
+#endif
+
+#ifdef USE_STM32F4XX_NUCLEO
+#include "stm32f4xx_hal.h"
+#endif
+#include "SPIRIT_Config.h"
+#include "radio_spi.h" 
+// #include "spirit1-arch.h"
+
+/**
+ * @addtogroup BSP
+ * @{
+ */ 
+  
+/* Exported types ------------------------------------------------------------*/
+
+  
+/* Exported constants --------------------------------------------------------*/
+  
+  
+/* Exported macro ------------------------------------------------------------*/
+  /* Define for SPIRIT1 board  */  
+ #if !defined (USE_SPIRIT1_DEFAULT)
+ #define USE_SPIRIT1_DEFAULT
+#endif
+  
+/* SPIRIT1_Spi_config */ 
+/* SPI1 */  
+#define RADIO_SPI                                 SPI1
+#define RADIO_SPI_CLK_ENABLE()                  __SPI1_CLK_ENABLE()
+#define RADIO_SPI_CLK_DISABLE()                 __SPI1_CLK_DISABLE()
+
+#define RADIO_SPI_MISO_PORT                      GPIOA
+#define RADIO_SPI_MISO_PIN                       GPIO_PIN_6
+#define RADIO_SPI_MISO_CLOCK_ENABLE()            __GPIOA_CLK_ENABLE()
+#define RADIO_SPI_MISO_CLOCK_DISABLE()           __GPIOA_CLK_DISABLE() 
+  
+#define RADIO_SPI_MOSI_PORT                      GPIOA
+#define RADIO_SPI_MOSI_PIN                       GPIO_PIN_7
+#define RADIO_SPI_MOSI_CLOCK_ENABLE()            __GPIOA_CLK_ENABLE()
+#define RADIO_SPI_MOSI_CLOCK_DISABLE()           __GPIOA_CLK_DISABLE()   
+  
+ 
+ 
+#ifdef USE_SPIRIT1_DEFAULT    
+
+#define RADIO_SPI_SCK_PORT                      GPIOB
+#define RADIO_SPI_SCK_PIN                       GPIO_PIN_3
+#define RADIO_SPI_SCK_CLOCK_ENABLE()            __GPIOB_CLK_ENABLE()
+#define RADIO_SPI_SCK_CLOCK_DISABLE()           __GPIOB_CLK_DISABLE()
+
+  
+#define RADIO_SPI_CS_PORT                        GPIOB
+#define RADIO_SPI_CS_PIN                         GPIO_PIN_6
+#define RADIO_SPI_CS_CLOCK_ENABLE()            __GPIOB_CLK_ENABLE()
+#define RADIO_SPI_CS_CLOCK_DISABLE()           __GPIOB_CLK_DISABLE()
+ 
+#else 
+ 
+#define RADIO_SPI_SCK_PORT                      GPIOB
+#define RADIO_SPI_SCK_PIN                       GPIO_PIN_3
+#define RADIO_SPI_SCK_CLOCK_ENABLE()            __GPIOB_CLK_ENABLE()
+#define RADIO_SPI_SCK_CLOCK_DISABLE()           __GPIOB_CLK_DISABLE()
+
+  
+#define RADIO_SPI_CS_PORT                        GPIOB
+#define RADIO_SPI_CS_PIN                         GPIO_PIN_6
+#define RADIO_SPI_CS_CLOCK_ENABLE()            __GPIOB_CLK_ENABLE()
+#define RADIO_SPI_CS_CLOCK_DISABLE()           __GPIOB_CLK_DISABLE()
+    
+#endif  
+  
+/* Maximum Timeout values for flags waiting loops. These timeouts are not based
+   on accurate values, they just guarantee that the application will not remain
+   stuck if the SPI communication is corrupted.
+   You may modify these timeout values depending on CPU frequency and application
+   conditions (interrupts routines ...) */    
+#define RADIO_SPI_TIMEOUT_MAX                   ((uint32_t)1000)
+
+/* SPIRIT1_Spi_config_Private_Defines */  
+#define CS_TO_SCLK_DELAY     0x0200//FIXME what is this doing?
+#define CLK_TO_CS_DELAY      0x0001
+  
+/* SPIRIT1_Spi_config_Headers */
+#define HEADER_WRITE_MASK     0x00                                /*!< Write mask for header byte*/
+#define HEADER_READ_MASK      0x01                                /*!< Read mask for header byte*/
+#define HEADER_ADDRESS_MASK   0x00                                /*!< Address mask for header byte*/
+#define HEADER_COMMAND_MASK   0x80                                /*!< Command mask for header byte*/
+  
+#define LINEAR_FIFO_ADDRESS 0xFF                                  /*!< Linear FIFO address*/
+  
+/* SPIRIT1_Spi_config_Private_FunctionPrototypes */
+#define SPI_ENTER_CRITICAL()         IRQ_DISABLE()
+#define SPI_EXIT_CRITICAL()          IRQ_ENABLE()
+  
+/* SPIRIT1_Spi_config_Private_Functions */
+#define RadioSpiCSLow()        HAL_GPIO_WritePin(RADIO_SPI_CS_PORT, RADIO_SPI_CS_PIN, GPIO_PIN_RESET)
+#define RadioSpiCSHigh()       HAL_GPIO_WritePin(RADIO_SPI_CS_PORT, RADIO_SPI_CS_PIN, GPIO_PIN_SET)
+  
+/* SPIRIT1_Spi_config_Private_Macros */
+#define BUILT_HEADER(add_comm, w_r) (add_comm | w_r)                             /*!< macro to build the header byte*/
+#define WRITE_HEADER        BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_WRITE_MASK) /*!< macro to build the write 
+                                                                                                         header byte*/
+#define READ_HEADER         BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_READ_MASK)  /*!< macro to build the read 
+                                                                                                         header byte*/
+#define COMMAND_HEADER      BUILT_HEADER(HEADER_COMMAND_MASK, HEADER_WRITE_MASK) /*!< macro to build the command 
+                                                                                                         header byte*/
+  
+  
+  
+/* Exported Variables --------------------------------------------------------*/
+  
+  
+/* Exported functions ------------------------------------------------------- */ 
+void SdkEvalSpiInit(void);
+void SpiCSGpioSetLevel(GPIO_PinState xState);
+StatusBytes SdkEvalSpiWriteRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer);
+StatusBytes SdkEvalSpiReadRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer);
+StatusBytes SdkEvalSpiCommandStrobes(uint8_t cCommandCode);
+StatusBytes SdkEvalSpiWriteFifo(uint8_t cNbBytes, uint8_t* pcBuffer);
+StatusBytes SdkEvalSpiReadFifo(uint8_t cNbBytes, uint8_t* pcBuffer);
+
+  
+#ifdef __cplusplus
+}
+#endif
+#endif /*__RADIO_SPI_H */
+
+/**
+* @}
+*/
+
+/**
+* @}
+*/
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/