From b24866225a6301d3a663f874725e83c012dc25d3 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 26 Dec 2012 17:36:00 +0100 Subject: digital/beacon: add bitcloud stack into common directory digital/zigbit --- .../avr/atmega1281/zigBit/include/halAtmelUid.h | 68 ++++++++++ .../HAL/avr/atmega1281/zigBit/include/halMacIsr.h | 77 +++++++++++ .../HAL/avr/atmega1281/zigBit/include/halRfCtrl.h | 142 +++++++++++++++++++++ .../HAL/avr/atmega1281/zigBit/include/halRfPio.h | 41 ++++++ .../HAL/avr/atmega1281/zigBit/include/halRfSpi.h | 79 ++++++++++++ 5 files changed, 407 insertions(+) create mode 100644 digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halAtmelUid.h create mode 100644 digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halMacIsr.h create mode 100644 digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfCtrl.h create mode 100644 digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfPio.h create mode 100644 digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfSpi.h (limited to 'digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include') diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halAtmelUid.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halAtmelUid.h new file mode 100644 index 00000000..d3931966 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halAtmelUid.h @@ -0,0 +1,68 @@ +/**************************************************************************//** + \file halAtmelUid.h + + \brief The header file describes the UID interface for Atmel MeshBean. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 10/12/10 A. Malkin - Created + ******************************************************************************/ +/****************************************************************************** + * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. * + * EXPERT USERS SHOULD PROCEED WITH CAUTION. * + ******************************************************************************/ + +#ifndef _HALATMELUID_H +#define _HALATMELUID_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ +#define SINGLE_WIRE_SUCCESS_STATUS 0 +#define SINGLE_WIRE_ERROR_STATUS -1 + +/****************************************************************************** + Types section +******************************************************************************/ +/** \brief uid type. */ +typedef union +{ + uint64_t uid; + uint8_t array[sizeof(uint64_t)]; +} HalUid_t; + +/****************************************************************************** + Inline static functions prototypes section. +******************************************************************************/ +HAL_ASSIGN_PIN(SINGLE_WIRE, G, 5); // Macros for the Single-wire pin actions. + +/****************************************************************************** + Prototypes section +******************************************************************************/ +/**************************************************************************//** +\brief Reads Atmel MeshBean UID from ATTiny13A + +\param[in] uidBuffer - memory for unique ID. + +\return + SINGLE_WIRE_SUCCESS_STATUS - if UID read successfully; + SINGLE_WIRE_ERROR_STATUS - if error occured during UID read. +******************************************************************************/ +int halReadAtmelMeshbeanUid(uint8_t *uidBuffer); + +#endif /* _HALATMELUID_H */ + +// eof halAtmelUid.h diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halMacIsr.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halMacIsr.h new file mode 100644 index 00000000..127af1ee --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halMacIsr.h @@ -0,0 +1,77 @@ +/**************************************************************************//** + \file halMacIsr.h + + \brief Declaration mac timer interface. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 14/01/08 A. Mandychev - Created. + ******************************************************************************/ +/****************************************************************************** + * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. * + * EXPERT USERS SHOULD PROCEED WITH CAUTION. * + ******************************************************************************/ + +#ifndef _HALMACISR_H +#define _HALMACISR_H + +/****************************************************************************** + Includes section. +******************************************************************************/ +#include + +/****************************************************************************** + Types section. +******************************************************************************/ +typedef enum +{ + HAL_RTIMER_REPEAT_MODE = 0, + HAL_RTIMER_ONE_SHOT_MODE = 1, + HAL_RTIMER_STOPPED_MODE = 2, +} HAL_RTimerMode_t; + +typedef struct // Timer description. +{ + volatile HAL_RTimerMode_t mode; // Mode. + volatile uint16_t period; // Period of the timer. + volatile uint16_t nextEvent; // Counter of periods. +} RTimerDescr_t; + +/****************************************************************************** + External variables. +******************************************************************************/ +// Do not use it in other files. +extern RTimerDescr_t __rtimer; + +/****************************************************************************** + Prototypes section. +******************************************************************************/ +/****************************************************************************** + Initializes Rtimer and RF ext. interrupts. +******************************************************************************/ +void HAL_InitMacIsr(void); + +/****************************************************************************** + Starts RTimer. Function should be invoked in critical section. + Parameters: + source - source of invocation. + mode - RTimer mode. + period - RTimer period. +******************************************************************************/ +bool HAL_StartRtimer(HAL_RTimerMode_t mode, uint16_t period); + +/****************************************************************************** + Stops RTimer. Function should be invoked in critical section. +******************************************************************************/ +void HAL_StopRtimer(void); + +#endif /* _HALMACISR_H */ + +// eof halMacIsr.h diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfCtrl.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfCtrl.h new file mode 100644 index 00000000..846b101c --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfCtrl.h @@ -0,0 +1,142 @@ +/**************************************************************************//** + \file halRfCtrl.h + + \brief Types and constants declaration for IEEE802.15.4 PHY implementation. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 28/05/07 ALuzhetsky - Created. + 06/08/07 A. Mandychev, E. Ivanov - Modified. + ******************************************************************************/ +/****************************************************************************** + * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. * + * EXPERT USERS SHOULD PROCEED WITH CAUTION. * + ******************************************************************************/ + +#ifndef _HALRFCTRL_H +#define _HALRFCTRL_H + +/****************************************************************************** + Includes section. +******************************************************************************/ +#include + +/****************************************************************************** + Types section +******************************************************************************/ +typedef enum +{ + HAL_FREQ_NOCLK, + HAL_FREQ_1MHZ, + HAL_FREQ_2MHZ, + HAL_FREQ_4MHZ, + HAL_FREQ_8MHZ, + HAL_FREQ_16MHZ +} HalSysFreq_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ +/****************************************************************************** + Delay in us +******************************************************************************/ +void HAL_Delay(uint8_t us); + +/****************************************************************************** + Clears the irq. +******************************************************************************/ +void HAL_ClearRfIrqFlag(void); + +/****************************************************************************** + Enables the irq. +******************************************************************************/ +void HAL_EnableRfIrq(void); + +/****************************************************************************** + Disables the irq. +******************************************************************************/ +uint8_t HAL_DisableRfIrq(void); + +/****************************************************************************** + Sets SLP_TR pin to 1. +******************************************************************************/ +void HAL_SetRfSlpTr(void); + +/****************************************************************************** + Clears SLP_TR pin to 0. +******************************************************************************/ +void HAL_ClearRfSlpTr(void); + +/****************************************************************************** + Makes SLP_TR pin as input. +******************************************************************************/ +void HAL_MakeInRfSlpTr(void); + +/****************************************************************************** + Makes SLP_TR pin as input. +******************************************************************************/ +void HAL_MakeOutRfSlpTr(void); + +/****************************************************************************** + Sets RST_TR pin to 1. +******************************************************************************/ +void HAL_SetRfRst(void); + +/****************************************************************************** + Clears RST_TR pin to 1. +******************************************************************************/ +void HAL_ClearRfRst(void); + +/****************************************************************************** + Init pins that controls RF chip. +******************************************************************************/ +void HAL_InitRfPins(void); + +/****************************************************************************** + Inits Atmega IRQ pin. +******************************************************************************/ +void HAL_InitRfIrq(void); + +/****************************************************************************** + Returns current frequency code. +******************************************************************************/ +HalSysFreq_t HAL_GetRfFreq(void); + +/**************************************************************************//** + \brief Wait for when radio will be waked up. + + \param none. + \return none. +******************************************************************************/ +void halWaitRadio(void); + +/**************************************************************************//** + \brief Enables RX TX indicator for radio if that is supported. +******************************************************************************/ +void HAL_EnableRxTxSwitcher(void); + +/**************************************************************************//** + \brief Enables Antenna diversity option for radio if that is supported. +******************************************************************************/ +void HAL_InitAntennaDiversity(void); + +/**************************************************************************//** + \brief Enables Antenna diversity in RX mode for radio if that is supported. +******************************************************************************/ +void HAL_EnableRxAntennaDiversity(void); + +/**************************************************************************//** + \brief Enables Antenna diversity in TX mode for radio if that is supported. +******************************************************************************/ +void HAL_EnableTxAntennaDiversity(void); + +#endif /* _HALRFCTRL_H */ + +// eof halRfCtrl.h diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfPio.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfPio.h new file mode 100644 index 00000000..05f3f296 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfPio.h @@ -0,0 +1,41 @@ +/**************************************************************************//** + \file halRfPio.h + + \brief AT86RF230 control pins declarations. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 29/05/07 A. Luzhetsky - Created + ******************************************************************************/ +/****************************************************************************** + * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. * + * EXPERT USERS SHOULD PROCEED WITH CAUTION. * + ******************************************************************************/ + +#ifndef _HALRFPIO_H +#define _HALRFPIO_H + +#include + +// Macros for the RF_SLP_TR pin manipulation. +HAL_ASSIGN_PIN(RF_SLP_TR, B, 4); +// Macros for the RF_RST pin manipulation. +HAL_ASSIGN_PIN(RF_RST, A, 7); +// Macros for the RF_IRQ pin manipulation. +HAL_ASSIGN_PIN(RF_IRQ, E, 5); +// Macros for the SPI_CS pin manipulation. +HAL_ASSIGN_PIN(SPI_CS, B, 0); +// Macros for the SPI_SCK pin manipulation. +HAL_ASSIGN_PIN(SPI_SCK, B, 1); +// Macros for the SPI_MOSI pin manipulation. +HAL_ASSIGN_PIN(SPI_MOSI, B, 2); +// Macros for the SPI_MISO pin manipulation. +HAL_ASSIGN_PIN(SPI_MISO, B, 3); +#endif /* _HALRFPIO_H */ diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfSpi.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfSpi.h new file mode 100644 index 00000000..fe3328a6 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfSpi.h @@ -0,0 +1,79 @@ +/***************************************************************************//** + \file halRfSpi.h + + \brief SPI interface routines header. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 29/05/07 A. Luzhetsky - Created + ******************************************************************************/ +/****************************************************************************** + * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. * + * EXPERT USERS SHOULD PROCEED WITH CAUTION. * + ******************************************************************************/ + +#ifndef _HALRFSPI_H +#define _HALRFSPI_H + +/****************************************************************************** + Includes section. +******************************************************************************/ +#include +#include +#include +#include + +/****************************************************************************** + Prototypes section +******************************************************************************/ +/****************************************************************************** + Performs initialization of SPI interface. +******************************************************************************/ +void HAL_InitRfSpi(void); + +/****************************************************************************** + Writes/reads byte to/from SPI. + parameters: value - byte to write. + Returns: the byte which was read. +******************************************************************************/ +uint8_t HAL_WriteByteRfSpi(uint8_t value); + +/****************************************************************************** + Deselects a slave device. +******************************************************************************/ +void HAL_DeselectRfSpi(void); + +/****************************************************************************** + Selects a slave device. +******************************************************************************/ +void HAL_SelectRfSpi(void); + +/****************************************************************************** + Inline function (to use in critical sections) + Writes/reads byte to/from SPI. + parameters: value - byte to write. + Returns: the byte which was read. +******************************************************************************/ +INLINE uint8_t HAL_WriteByteInlineRfSpi(uint8_t value) +{ + ATOMIC_SECTION_ENTER + BEGIN_MEASURE + SPDR = value; // Write data. + asm("nop"); // This "nop" tunes up the "while" to reduce time for SPIF flag + // detecting. + while (!(SPSR&(1 << SPIF))); + END_MEASURE(HALATOM_WRITEBYTE_RFSPI_TIME_LIMIT) + ATOMIC_SECTION_LEAVE + return SPDR; +} + +#endif /* _HALRFSPI_H */ + +//eof halRfSpi.h -- cgit v1.2.3