Zigbee Module Examples

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
hal_fram.c File Reference

Hardware Abstraction Layer (HAL) for the TI MSP-EXP430FR5739 and Anaren Zigbee BoosterPack. More...

`#include "hal_fram.h"`
`#include <stdint.h>`

## Functions
__interrupt void | USCI_A0_ISR (void)
__interrupt void | PORT4_ISR (void)
void | doNothing (int8_t a)
void | oscInit ()
void | halInit ()
int | putchar (int c)
void | halSpiInitModule ()
void | spiWrite (uint8_t *bytes, uint8_t numBytes)
void | delayMs (uint16_t delay)
int16_t | setLed (uint8_t led)
void | clearLeds ()
int16_t | toggleLed (uint8_t led)

## Variables
void(* | debugConsoleIsr )(int8_t)
void(* | buttonIsr )(int8_t)
void(* | timerIsr )(void)
void(* | srdyIsr )(void)
uint16_t | wakeupFlags = 0
uint16_t | vloFrequency = 0

## Detailed Description

Hardware Abstraction Layer (HAL) for the TI MSP-EXP430FR5739 and Anaren Zigbee BoosterPack.

This file must be modified if changing hardware platforms.

The Zigbee Module library & examples require several methods to be defined. See hal_helper documentation. Also see hal_fram.h for macros that must be defined.

See also:
  hal_helper.c for utilities to assist when changing hardware platforms
  "Migrating from the MSP430F2xx Family to the MSP430FR57xx Family" (slaa499) from TI
  "Migrating from the USCI Module to the eUSCI Module" (slaa522) from TI

Rev:
  1528

Author:
  dsmith

Date:
  2012-08-30 15:58:08 -0700 (Thu, 30 Aug 2012)

# Support

Please refer to the wiki at www.anaren.com/air-wiki-zigbee for more information. Additional support is available via email at the following addresses:

- Questions on how to use the product: AIR@a.nosp@m.nare.nosp@m.n.com
- Feature requests, comments, and improvements: featu.nosp@m.rere.nosp@m.quest.nosp@m.s@te.nosp@m.slaco.nosp@m.ntro.nosp@m.ls.co.nosp@m.m
- Consulting engagements: sales.nosp@m.@tes.nosp@m.lacon.nosp@m.trol.nosp@m.s.com

# License

Copyright (c) 2012 Tesla Controls. All rights reserved. This Software may only be used with an Anaren A2530E24AZ1, A2530E24CZ1, A2530R24AZ1, or A2530R24CZ1 module. Redistribution and use in source and binary forms, with or without modification, are subject to the Software License Agreement in the file "anaren_eula.txt"

YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL ANAREN MICROWAVE OR TESLA CONTROLS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSE INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

# connection notes

    P1 on CC2530DK connects to RF1 on FRAM board
    P2 on CC2530DK connects to RF2 on FRAM board
    P1/RF1 pins:
    Pin CC2530  Name    FRAM
    1   GND             GND
    2   n/c
    3   ccP0.4  SRDY    mspP2.4
    4   ccP1.3  EN(N/C)
    5   ccP0.1  GPIO1   mspP1.0
    6   ccP1.0  GPIO3   mspP1.1
    7   ccP0.2          mspP1.1
    8   N/C             mspP1.2
    9   ccP0.3  MRDY    mspP1.2 (duplicate)
    10  ccP2.1          mspP4.1
    11  ccP0.0  GPIO0
    12  ccP2.2          mspP2.3
    13  ccP1.1  PAEN(N/C)
    14  ccP1.4  SS      mspP1.3 UCB0STE
    15  ccP0.6  GPIO2
    16  ccP1.5  SCLK    mspP2.2 UCB0CLK
    17  ccP0.7  HGM(N/C)
    18  ccP1.6  MOSI    mspP1.6 UCB0SIMO
    19  GND             GND
    20  ccP1.7  MISO    mspP1.7 UCB0SOMI

    P2/RF2
    Pin CC2530          FRAM
    1
    2                     GND
    3
    4
    5
    6
    7   VCC             RFPWR
    8
    9   VCC             RFPWR
    10
    11
    12
    13                  mspP2.0
    14
    15  ccRST   reset   mspP1.0 (duplicate)
    16
    17  ccP1.2  CFG0
    18  ccP0.5          mspP2.7
    19  ccP2.0  CFG1    mspP4.0   Tie Hi for SPI
    20                  mspP3.7

## Function Documentation

void clearLeds | ( |  | ) |

Turns OFF LEDs.

Postcondition:
  LEDs are turned off.

void delayMs | ( | uint16_t | delay | ) |

A fairly accurate blocking delay for waits in the millisecond range. Good for 1mSec to 1000mSec. At 1MHz, error of zero for 100mSec or 1000mSec. For 10mSec, error of 100uSec. At 1mSec, error is 20uSec. At 8MHz, error of zero for 1000mSec. Note that accuracy will depend on the clock source. MSP430F2xx internal DCO is typically +/-1%. For better timing accuracy, use a timer, or a crystal.

Precondition:
  TICKS_PER_MS is defined correctly

Parameters:

  delay | number of milliseconds to delay

void doNothing | ( | int8_t | a | ) |

Simple placeholder to point the function pointers to so that they don't cause mischief

void halInit | ( |  | ) |

Configures hardware for the particular hardware platform:

- Ports: sets direction, interrupts, pullup/pulldown resistors etc.
- Holds radio in reset (active-low)

void halSpiInitModule | ( |  | ) |

Initializes the Serial Peripheral Interface (SPI) interface to the Zigbee Module (ZM).

Note:
  Maximum module SPI clock speed is 4MHz. SPI port configured for clock polarity of 0, clock phase of 0, and MSB first.
  On the FRAM board the MSP430 uses USCIB0 SPI port to communicate with the module.

Precondition:
  SPI pins configured correctly:
  - Clock, MOSI, MISO configured as SPI function
  - Chip Select configured as an output
  - SRDY configured as an input.

Postcondition:
  SPI port is configured for communications with the module.

void oscInit | ( |  | ) |

Initializes Oscillator: turns off WDT, configures MCLK = 8MHz using internal DCO & sets SMCLK = 4MHz.

See also:
  MSP430FR57xx_UCS_01.c

__interrupt void PORT4_ISR | ( | void |  | ) |

Port 4 interrupt service routine, called when an interrupt-enabled pin on port 4 changes state.

int putchar | ( | int | c | ) |

Send one byte via hardware UART. Required for printf() etc. in stdio.h

int16_t setLed | ( | uint8_t | led | ) |

Turns ON the specified LED.

Parameters:

  led | the LED to turn on

Postcondition:
  The specified LED is turned on.

Returns:
  0 if success, -1 if invalid LED specified

void spiWrite | ( | uint8_t * | bytes,
|  | uint8_t | numBytes
| ) |  |

Sends a message over SPI to the Module. The Module uses a "write-to-read" approach: to read data out, you must write data in. This is a private method that gets wrapped by other methods, e.g. spiSreq(), spiAreq, etc. To Write, set *bytes and numBytes. To Read, set *bytes only. Don't need to set numBytes because the Module will stop when no more bytes are received.

Parameters:

  bytes | the data to be sent or received.
  numBytes | the number of bytes to be sent. This same buffer will be overwritten with the received data.

Precondition:
  SPI port configured for the Module and Module has been initialized properly

Postcondition:
  bytes contains received data, if any

int16_t toggleLed | ( | uint8_t | led | ) |

Toggles the specified LED.

Parameters:

  led | the LED to toggle.

Postcondition:
  The specified LED is toggled.

Returns:
  0 if success, -1 if invalid LED specified

__interrupt void USCI_A0_ISR | ( | void |  | ) |

Debug console interrupt service routine, called when a byte is received on USCIA0.

## Variable Documentation

void(* buttonIsr)(int8_t)

    Function pointer for the ISR called when the button is pressed.

Parameter is which button was pressed.

void(* debugConsoleIsr)(int8_t)

    This is a function pointer for the Interrupt Service Routine called when a debug console character is received.

To use it, declare it with `extern void (*debugConsoleIsr)(char);` and then point it to a function you created, e.g. `debugConsoleIsr =` and your function handleDebugConsoleInterrupt() will be called when a byte is received on the debug serial port.

void(* srdyIsr)(void)

Function pointer for the ISR called when a SRDY interrupt occurs

void(* timerIsr)(void)

Function pointer for the ISR called when a timer generates an interrupt

uint16_t vloFrequency = 0

    The post-calibrated frequency of the Very Low Oscillator (VLO).

This MUST be calibrated by calibrateVlo() prior to use. Set with calibrateVlo() and read by initTimer().

uint16_t wakeupFlags = 0

    Flags to indicate when to wake up the processor. These are read in the various ISRs.

If the flag is set then the processor will be woken up with HAL_WAKEUP() at the end of the ISR. This is required because HAL_WAKEUP() cannot be called anywhere except in an ISR.