HelloWorld_IDS01A4 mbed application for Spirit1 P2P demo.

Dependencies:   mbed

Fork of HelloWorld_IDS01A5_Program by rosarium pila

mbed 2.0 (a.k.a classic) HelloWorld example for Spirit1 to transfer data from one node to another.
To send the predefined data packet from the sender to the receiver, user needs to press User Button on the board. The LED on the receiver expansion board will toggle on reception of data successfully.
Data packets sent and received can be seen on USB serial terminal.

EVALUATION BOARDS RF FREQUENCY DESCRIPTION :
X-NUCLEO-IDS01A4 868 MHz 868 MHz RF expansion board based on SPIRIT1

Committer:
rosarium
Date:
Thu May 25 16:38:55 2017 +0000
Revision:
0:2ddc0583bcec
First draft version of HelloWorld_IDS01A5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rosarium 0:2ddc0583bcec 1 /*
rosarium 0:2ddc0583bcec 2 * Copyright (c) 2012, STMicroelectronics.
rosarium 0:2ddc0583bcec 3 * All rights reserved.
rosarium 0:2ddc0583bcec 4 *
rosarium 0:2ddc0583bcec 5 * Redistribution and use in source and binary forms, with or without
rosarium 0:2ddc0583bcec 6 * modification, are permitted provided that the following conditions
rosarium 0:2ddc0583bcec 7 * are met:
rosarium 0:2ddc0583bcec 8 * 1. Redistributions of source code must retain the above copyright
rosarium 0:2ddc0583bcec 9 * notice, this list of conditions and the following disclaimer.
rosarium 0:2ddc0583bcec 10 * 2. Redistributions in binary form must reproduce the above copyright
rosarium 0:2ddc0583bcec 11 * notice, this list of conditions and the following disclaimer in the
rosarium 0:2ddc0583bcec 12 * documentation and/or other materials provided with the distribution.
rosarium 0:2ddc0583bcec 13 * 3. Neither the name of the Institute nor the names of its contributors
rosarium 0:2ddc0583bcec 14 * may be used to endorse or promote products derived from this software
rosarium 0:2ddc0583bcec 15 * without specific prior written permission.
rosarium 0:2ddc0583bcec 16 *
rosarium 0:2ddc0583bcec 17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
rosarium 0:2ddc0583bcec 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
rosarium 0:2ddc0583bcec 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
rosarium 0:2ddc0583bcec 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
rosarium 0:2ddc0583bcec 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
rosarium 0:2ddc0583bcec 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
rosarium 0:2ddc0583bcec 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
rosarium 0:2ddc0583bcec 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
rosarium 0:2ddc0583bcec 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
rosarium 0:2ddc0583bcec 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
rosarium 0:2ddc0583bcec 27 * SUCH DAMAGE.
rosarium 0:2ddc0583bcec 28 *
rosarium 0:2ddc0583bcec 29 * This file is part of the Contiki operating system.
rosarium 0:2ddc0583bcec 30 *
rosarium 0:2ddc0583bcec 31 */
rosarium 0:2ddc0583bcec 32 /*---------------------------------------------------------------------------*/
rosarium 0:2ddc0583bcec 33 #ifndef __SPIRIT1_CONFIG_H__
rosarium 0:2ddc0583bcec 34 #define __SPIRIT1_CONFIG_H__
rosarium 0:2ddc0583bcec 35 /*---------------------------------------------------------------------------*/
rosarium 0:2ddc0583bcec 36 #include "radio.h"
rosarium 0:2ddc0583bcec 37 #include "SPIRIT_Config.h"
rosarium 0:2ddc0583bcec 38 #include "spirit1-const.h"
rosarium 0:2ddc0583bcec 39 /*---------------------------------------------------------------------------*/
rosarium 0:2ddc0583bcec 40 #define CCA_THRESHOLD -98.0 /* dBm */
rosarium 0:2ddc0583bcec 41 #define XTAL_FREQUENCY 50000000 /* Hz */
rosarium 0:2ddc0583bcec 42 #define SPIRIT_MAX_FIFO_LEN (96) // betzw - WAS: 600
rosarium 0:2ddc0583bcec 43 /*---------------------------------------------------------------------------*/
rosarium 0:2ddc0583bcec 44
rosarium 0:2ddc0583bcec 45 /* Sometimes Spirit1 seems to NOT deliver (correctly) the 'IRQ_RX_DATA_READY'
rosarium 0:2ddc0583bcec 46 * event for packets which have a length which is close to a multiple of
rosarium 0:2ddc0583bcec 47 * RX FIFO size. Furthermore, in these cases also the content delivery seems
rosarium 0:2ddc0583bcec 48 * to be compromised as well as the generation of RX/TX FIFO errors.
rosarium 0:2ddc0583bcec 49 * This can be avoided by reducing the maximum packet length to a value which
rosarium 0:2ddc0583bcec 50 * is lower than the RX FIFO size.
rosarium 0:2ddc0583bcec 51 *
rosarium 0:2ddc0583bcec 52 * Enable beyond macro if you want to use the version of the driver which avoids
rosarium 0:2ddc0583bcec 53 * FIFO overflows by reducing packet length.
rosarium 0:2ddc0583bcec 54 *
rosarium 0:2ddc0583bcec 55 * NOTE: the non delivery of event 'IRQ_RX_DATA_READY' MUST still be
rosarium 0:2ddc0583bcec 56 * investigated further deeply (both on HW & SW level)!
rosarium 0:2ddc0583bcec 57 */
rosarium 0:2ddc0583bcec 58 #define RX_FIFO_THR_WA
rosarium 0:2ddc0583bcec 59
rosarium 0:2ddc0583bcec 60 /**
rosarium 0:2ddc0583bcec 61 * The MAX_PACKET_LEN is an arbitrary value used to define the two array
rosarium 0:2ddc0583bcec 62 * spirit_txbuf and spirit_rxbuf.
rosarium 0:2ddc0583bcec 63 * The SPIRIT1 supports with its packet handler a length of 65,535 bytes,
rosarium 0:2ddc0583bcec 64 * and in direct mode (without packet handler) there is no limit of data.
rosarium 0:2ddc0583bcec 65 */
rosarium 0:2ddc0583bcec 66 #ifdef RX_FIFO_THR_WA
rosarium 0:2ddc0583bcec 67 #define MAX_PACKET_LEN (SPIRIT_MAX_FIFO_LEN-1)
rosarium 0:2ddc0583bcec 68 #else
rosarium 0:2ddc0583bcec 69 #define MAX_PACKET_LEN (255) // betzw - WAS: SPIRIT_MAX_FIFO_LEN, but LEN_WIDTH is set to 7 so the variable payload length is theoretically from 0 to 255 bytes
rosarium 0:2ddc0583bcec 70 #endif
rosarium 0:2ddc0583bcec 71
rosarium 0:2ddc0583bcec 72 /*---------------------------------------------------------------------------*/
rosarium 0:2ddc0583bcec 73 /**
rosarium 0:2ddc0583bcec 74 * Spirit1 IC version
rosarium 0:2ddc0583bcec 75 */
rosarium 0:2ddc0583bcec 76 #define SPIRIT1_VERSION SPIRIT_VERSION_3_0
rosarium 0:2ddc0583bcec 77 /*---------------------------------------------------------------------------*/
rosarium 0:2ddc0583bcec 78 #endif /* __SPIRIT1_CONFIG_H__ */
rosarium 0:2ddc0583bcec 79 /*---------------------------------------------------------------------------*/