Commit 2e85d380 authored by Edward Longman's avatar Edward Longman
Browse files

Add the correct configuration for 430FR5994, done using info from QuickStart...

Add the correct configuration for 430FR5994, done using info from QuickStart Pinout and Device User Guides
parent 3d5c4421
/******************************************************************************
* Filename: hal_f5_timerB0.c
* Filename: hal_fr5_timer.c
*
* Description: Timer abstration layer api
* Description: Timer abstration layer api for FR5994
*
* Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
*
......@@ -33,6 +33,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Modified by Edward Longman for the MSP430FR5994
*
*******************************************************************************/
#if defined (__MSP430FR5994__)
......@@ -62,10 +64,10 @@ void hal_timer_init(unsigned int master_count) {
// Start Timer 0 using the ACLK as a source (this enables the use of
// various low power modes). Timer 0 will be used to keep RF burst time
TBCCR0 = master_count - 1; // Seting for MASTER SCHEDULE
TBCCR1 = 0; // will be used for burst alignnment
TBCCR2 = 0; // will be used for expiration counter
TBCTL = TBSSEL_1 + MC_1 + TBCLR + ID_0;// ACLK, Up to CCR0, clear TB0R, div/1
TACCR0 = master_count - 1; // Seting for MASTER SCHEDULE
TACCR1 = 0; // will be used for burst alignnment
TACCR2 = 0; // will be used for expiration counter
TACTL = TASSEL_2 + MC_1 + TACLR + ID_0;// SMCLK, Up to CCR0, clear TB0R, div/1
return;
}
......@@ -88,7 +90,7 @@ void hal_timer_init(unsigned int master_count) {
*/
void hal_timer_adjust(unsigned int adjust) {
TB0R = adjust;
TA0R = adjust;
return;
}
......@@ -110,7 +112,7 @@ void hal_timer_adjust(unsigned int adjust) {
*/
unsigned int hal_timer_get(void) {
return(TB0R);
return(TA0R);
}
......@@ -138,12 +140,12 @@ unsigned int hal_timer_get_time(unsigned long *sec, unsigned long *ms) {
/* grap the time counter values from the global value */
*sec = time_counter;
/* grap the time counter value (1/32768) second resolution */
ms_uint = TB0R;
/* grap the time counter value (1/250000) second resolution */
ms_uint = TA0R;
/* convert information to milliseconds */
ms_long = (unsigned long)ms_uint * 1000;
ms_long = ms_long>>15;
ms_long = ms_long>>18;
*ms = ms_long;
/* return count value */
......@@ -169,7 +171,7 @@ unsigned int hal_timer_get_time(unsigned long *sec, unsigned long *ms) {
void hal_timer_stop(void) {
/* clear timer configuration register, stopping the timer */
TBCTL = 0;
TACTL = 0;
return;
}
......@@ -192,13 +194,13 @@ void hal_timer_stop(void) {
void hal_timer_expire(void) {
/* enable timer interrupt */
TBCCTL1 = CCIE;
TACCTL1 = CCIE;
/* enter low power mode and wait */
_BIS_SR(LPM0_bits + GIE);
/* disable interrupt again */
TBCCTL1 = 0;
TACCTL1 = 0;
return;
}
......@@ -219,76 +221,55 @@ void hal_timer_expire(void) {
*
*/
unsigned int hal_timer_wait(unsigned int time) {
unsigned int wait_count, TBR_init;
unsigned int wait_count, TAR_init;
TBR_init = TB0R; // store the current value of the timer register
wait_count = TBR_init + time;
TAR_init = TA0R; // store the current value of the timer register
wait_count = TAR_init + time;
// if the requested wait time exceeds the TBCCR0 (max value) then make a loop
while(wait_count > TBCCR0) {
// if the requested wait time exceeds the TACCR0 (max value) then make a loop
while(wait_count > TACCR0) {
// configure the timeout for 1 less than the master clock
TBCCR2 = TBCCR0-1;
TACCR2 = TACCR0-1;
// calculate the remaining wait time remaining
wait_count = wait_count - (TBCCR2 - TBR_init);
wait_count = wait_count - (TACCR2 - TAR_init);
// do not count the initial timer values more that once, zero it out
timer_event = 0;
TBR_init = 0;
TAR_init = 0;
// enable interupts and wait for timer (or CC1x GDO ISR)
TBCCTL2 = CCIE; // interrupt enabled
TACCTL2 = CCIE; // interrupt enabled
_BIS_SR(LPM0_bits + GIE); // Enter LPM0
// check to see if the timer woke us up or not
if (timer_event == 0)
// it did not, return imidiately and note time actual delay
return (time - (wait_count - TB0R));
return (time - (wait_count - TA0R));
}
// in the case of loop, this executes the remaining wait, in the case of no
// loop this is the only wait that gets executed
/* define maximum timeout by using timer counter 2 */
TBCCR2 = wait_count;
TACCR2 = wait_count;
/* enable interrupt */
TBCCTL2 = CCIE;
TACCTL2 = CCIE;
/* enter low power mode and wait for event (timer or radio) */
_BIS_SR(LPM0_bits + GIE);
/* disable interupts on CCR2 */
TBCCTL2 = 0;
TACCTL2 = 0;
/* return the time spend in sleep */
return (time - (wait_count-TB0R));
}
/******************************************************************************
* @fn TIMERB0_ISR
*
* @brief Timer interrupt service routine
*
*
* input parameters
*
* @param void
*
* output parameters
*
* @return void
*
*/
// Timer B0 interrupt service routine
#pragma vector=TIMERB0_VECTOR
__interrupt void TIMERB0_ISR (void) {
//_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
return (time - (wait_count-TA0R));
}
/******************************************************************************
* @fn TIMERB0_ISR
* @fn TIMERA2_ISR
*
* @brief Timer interrupt service routine
*
......@@ -302,31 +283,32 @@ __interrupt void TIMERB0_ISR (void) {
* @return void
*
*/
#pragma vector=TIMERB1_VECTOR
__interrupt void TIMERB1_ISR(void) {
void __attribute__((interrupt(TIMERA1_VECTOR))) TIMERA_ISR(void){
//#pragma vector=TIMERB1_VECTOR
//__interrupt void TIMERB1_ISR(void) {
/* Any access, read or write, of the TBIV register automatically
* resets the highest "pending" interrupt flag. */
switch( __even_in_range(TBIV,14) ) {
case TB0IV_NONE: break; // No interrupt
case TB0IV_TBCCR1: // Used to wake up radio from sleep
timer_event = TB0IV_TBCCR1;
switch( __even_in_range(TAIV,14) ) {
case TA0IV_NONE: break; // No interrupt
case TA0IV_TBCCR1: // Used to wake up radio from sleep
timer_event = TA0IV_TACCR1;
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
break;
case TB0IV_TBCCR2: // Use as secondary timer function
timer_event = TB0IV_TBCCR2;
case TA0IV_TACCR2: // Use as secondary timer function
timer_event = TA0IV_TACCR2;
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
break;
case TB0IV_TBCCR3: // CCR3 not used
case TA0IV_TACCR3: // CCR3 not used
break;
case TB0IV_TBCCR4: // CCR4 not used
case TA0IV_TACCR4: // CCR4 not used
break;
case TB0IV_TBCCR5: // CCR5 not used
case TA0IV_TACCR5: // CCR5 not used
break;
case TB0IV_TBCCR6: // CCR6 not used
case TA0IV_TACCR6: // CCR6 not used
break;
case TB0IV_TBIFG: // IFG not used
case TA0IV_TAIFG: // IFG not used
break;
default:
break;
......
......@@ -33,10 +33,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Modified by Edward Longman for the MSP430FR5994
*
*******************************************************************************/
#include "msp430.h"
#include "../radio_drv/hal_spi_rf.h"
// TODO Provide the define statements needed from this file.
#include "hal_spi_rf.h"
#if defined (__MSP430F5438A__)
/*******************************************************************************
......@@ -96,38 +99,37 @@ void msp_setup(void) {
* @return none
*******************************************************************************/
void msp_setup(void) {
// Enable the interupts on port 2 to catch the user button (TRXEB)
BUTTON_DIR &= ~BUTTON_PIN; // input direction
BUTTON_OUT |= BUTTON_PIN; // set high on port
BUTTON_PxIE |= BUTTON_PIN; // enable interupt
BUTTON_PxIES |= BUTTON_PIN; // Hi/lo edge
BUTTON_REN |= BUTTON_PIN; // Pull up resistor
BUTTON_PxIES &= ~BUTTON_PIN; // IFG cleared
// Setup the XTAL ports to use the external 32K oscillilator
P5SEL |= BIT4+BIT5; // Select XT1
UCSCTL6 |= XCAP_3; // Internal load cap
// Loop until XT1,XT2 & DCO stabilizes
do {
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
} while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive
// Set up clock system on MCU to fit your system
// Target specific implementation
UCSCTL0 = 0x00; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_6; // Select suitable range
UCSCTL2 = 488; // DCO = 488 * 32768Hz ~= 16MHz
UCSCTL4 = SELA__XT1CLK | SELS__DCOCLK | SELM__DCOCLK ;
// Setup Watch dog timer for 1 second tick using 32Khz XTAL on MSP430F5438A
WDTCTL = WDT_ADLY_1000; // WDT 15.6ms, ACLK, interval timer
SFRIE1 |= WDTIE; // Enable WDT interrupt
// Enable the interupts on port 2 to catch the user button (TRXEB)
BUTTON_DIR &= ~BUTTON_PIN; // input direction
BUTTON_OUT |= BUTTON_PIN; // set high on port
BUTTON_PxIE |= BUTTON_PIN; // enable interupt
BUTTON_PxIES |= BUTTON_PIN; // Hi/lo edge
BUTTON_REN |= BUTTON_PIN; // Pull up resistor
BUTTON_PxIES &= ~BUTTON_PIN; // IFG cleared
// Setup the XTAL ports to use the external 32K oscillilator
P5SEL |= BIT4+BIT5; // Select XT1
UCSCTL6 |= XCAP_3; // Internal load cap
// Loop until XT1,XT2 & DCO stabilizes
do {
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
} while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive
// Set up clock system on MCU to fit your system
// Target specific implementation
UCSCTL0 = 0x00; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_6; // Select suitable range
UCSCTL2 = 488; // DCO = 488 * 32768Hz ~= 16MHz
UCSCTL4 = SELA__XT1CLK | SELS__DCOCLK | SELM__DCOCLK ;
// Setup Watch dog timer for 1 second tick using 32Khz XTAL on MSP430F5438A
WDTCTL = WDT_ADLY_1000; // WDT 15.6ms, ACLK, interval timer
SFRIE1 |= WDTIE; // Enable WDT interrupt
}
#endif
......@@ -164,3 +166,41 @@ void msp_setup(void) {
}
#endif
#if defined (__MSP430FR5994__)
/*******************************************************************************
* @brief Setup all the peripherals of the MSP430, set the CPU speed to 16MHz,
* enable the 250kHz and configure WDT for a 1 sec tick speed.
*
* (MSP430FR5994 version)
*
* @param none
*
* @return none
*******************************************************************************/
void msp_setup(void) {
// Enable the interupts on port 2 to catch the user button (TRXEB)
BUTTON_DIR &= ~BUTTON_PIN; // input direction
BUTTON_OUT |= BUTTON_PIN; // set high on port
BUTTON_PxIE |= BUTTON_PIN; // enable interupt
BUTTON_PxIES |= BUTTON_PIN; // Hi/lo edge
BUTTON_REN |= BUTTON_PIN; // Pull up resistor
BUTTON_PxIES &= ~BUTTON_PIN; // IFG cleared
// Removed XTAL configuration and DCO Fault detection as not on exp430_fr5994
// Set up clock system on MCU to fit your system
// Target specific implementation
UCSCTL0 = 0x00; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_6; // Select suitable range
UCSCTL2 = 488; // DCO = 488 * 32768Hz ~= 16MHz
UCSCTL4 = SELA_LFXTCLK | SELS__DCOCLK | SELM__DCOCLK ;
// Setup Watch dog timer for 0.5 second tick using 16MHz DCO on MSP430FR5994
// WDT 0.5s @ 16mHz, SMCLK, interval timer
WDTCTL = WDTPWD + WDTSEL_0 + WDTTMSEL + WDTIS_2;
SFRIE1 |= WDTIE; // Enable WDT interrupt
}
#endif
......@@ -130,7 +130,7 @@ void trxRfSpiInterfaceInit(uint8 prescalerValue)
}
#endif
#if defined (__MSP430F5438A__) || defined (__MSP430F5529__)
#if defined (__MSP430F5438A__) || defined (__MSP430F5529__) || defined (__MSP430FR5994__)
/******************************************************************************
* @fn trxRfSpiInterfaceInit
......
......@@ -49,6 +49,9 @@
#if defined (__MSP430F5529__)
#include "hal_spi_rf_exp5529.h"
#endif
#if defined (__MSP430FR5994__)
#include "hal_spi_rf_exp430fr5994.h"
#endif
// CC Chip versions
#define DEV_UNKNOWN 10
......
/******************************************************************************
* Filename: hal_spi_rf_exp5529.h
* Filename: hal_spi_rf_exp430_fr5994.h
*
* Description: Common header file for spi access to the different tranceiver
* radios. Supports CC1101/CC112X radios
*
* Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
* Description: Common header file for spi access to different traceiver radios
* Supports CC112X radio.
*
* Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
......@@ -22,6 +18,10 @@
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Neither the name of Texas Instruments Incorporated 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
......@@ -34,6 +34,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Modified from hals_spi_rf_exp5594.h by Edward Longman
*
*******************************************************************************/
#ifndef HAL_SPI_RF_TRXEB_H
......@@ -53,84 +55,84 @@ extern "C" {
/******************************************************************************
* DEFINE THE TRANSCEIVER TO USE
*/
#define USE_CC1101 /* use the CC110x transciever commands */
//#define USE_CC112X /* use the CC112x transciever commands */
#define RF_XTAL 26000 /* default is 26000 for CC1101 */
//#define USE_CC1101 /* use the CC110x transciever commands */
#define USE_CC112X /* use the CC112x transciever commands */
#define RF_XTAL 32000 /* default is 26000 for CC1101 */
/* 32000 for CC1120 */
/* 40000 for CC1125 */
//#define ENABLE_RANGE_EXTENDER /* use external range extender */
#define ENABLE_RANGE_EXTENDER /* use external range extender */
/******************************************************************************
* CONSTANTS
*/
/* Transceiver SPI signal */
#define RF_PORT_SEL P3SEL
#define RF_PORT_OUT P3OUT
#define RF_PORT_DIR P3DIR
#define RF_PORT_IN P3IN
#define RF_PORT_SEL P5SEL
#define RF_PORT_OUT P5OUT
#define RF_PORT_DIR P5DIR
#define RF_PORT_IN P5IN
#define RF_MOSI_PIN BIT0
#define RF_MISO_PIN BIT1
#define RF_SCLK_PIN BIT2
/* Transceiver chip select signal */
#define RF_CS_N_PORT_SEL P2SEL
#define RF_CS_N_PORT_DIR P2DIR
#define RF_CS_N_PORT_OUT P2OUT
#define RF_CS_N_PIN BIT2
#define RF_CS_N_PORT_SEL P4SEL
#define RF_CS_N_PORT_DIR P4DIR
#define RF_CS_N_PORT_OUT P4OUT
#define RF_CS_N_PIN BIT4
/* Transciever optional reset signal */
#define RF_RESET_N_PORT_SEL P2SEL
#define RF_RESET_N_PORT_DIR P2DIR
#define RF_RESET_N_PORT_OUT P2OUT
#define RF_RESET_N_PIN BIT6
#define RF_RESET_N_PORT_SEL P8SEL
#define RF_RESET_N_PORT_DIR P8DIR
#define RF_RESET_N_PORT_OUT P8OUT
#define RF_RESET_N_PIN BIT3
/* CC1190 Control signals */
#define RF_LNA_EN_PxOUT P1OUT
#define RF_LNA_EN_PxDIR P1DIR
#define RF_LNA_EN_PIN BIT6
#define RF_LNA_EN_PxOUT P6OUT
#define RF_LNA_EN_PxDIR P6DIR
#define RF_LNA_EN_PIN BIT2
#define RF_PA_EN_PxOUT P2OUT
#define RF_PA_EN_PxDIR P2DIR
#define RF_PA_EN_PIN BIT7
#define RF_PA_EN_PxOUT P6OUT
#define RF_PA_EN_PxDIR P6DIR
#define RF_PA_EN_PIN BIT3
/* Transceiver interrupt configuration */
#define RF_PORT_VECTOR PORT2_VECTOR
#define RF_GDO_OUT P2OUT
#define RF_GDO_DIR P2DIR
#define RF_GDO_IN P2IN
#define RF_GDO_SEL P2SEL
#define RF_GDO_PxIES P2IES
#define RF_GDO_PxIFG P2IFG
#define RF_GDO_PxIE P2IE
#define RF_GDO_PIN BIT0
#define RF_PORT_VECTOR PORT5_VECTOR
#define RF_GDO_OUT P5OUT
#define RF_GDO_DIR P5DIR
#define RF_GDO_IN P5IN
#define RF_GDO_SEL P5SEL
#define RF_GDO_PxIES P5IES
#define RF_GDO_PxIFG P5IFG
#define RF_GDO_PxIE P5IE
#define RF_GDO_PIN BIT7
/* Optional button interrupt configuration */
#define BUTTON_VECTOR PORT1_VECTOR
#define BUTTON_OUT P1OUT
#define BUTTON_DIR P1DIR
#define BUTTON_IN P1IN
#define BUTTON_SEL P1SEL
#define BUTTON_PxIES P1IES
#define BUTTON_PxIFG P1IFG
#define BUTTON_PxIE P1IE
#define BUTTON_PIN BIT1
#define BUTTON_REN P1REN
#define BUTTON_VECTOR PORT5_VECTOR
#define BUTTON_OUT P5DIR
#define BUTTON_DIR P5DIR
#define BUTTON_IN P5IN
#define BUTTON_SEL P5SEL
#define BUTTON_PxIES P5IES
#define BUTTON_PxIFG P5IFG
#define BUTTON_PxIE P5IE
#define BUTTON_PIN BIT5
#define BUTTON_REN P5REN
/* Macro to enable LEDs */
#define LED1_PxOUT P1OUT
#define LED1_PxDIR P1DIR
#define LED1_PIN BIT0
#define LED2_PxOUT P4OUT
#define LED2_PxDIR P4DIR
#define LED2_PIN BIT7
#define LED2_PxOUT P1OUT
#define LED2_PxDIR P1DIR
#define LED2_PIN BIT1
#define LED3_PxOUT P1OUT
#define LED3_PxDIR P1DIR
#define LED3_PIN BIT0
#define LED4_PxOUT P4OUT
#define LED4_PxDIR P4DIR
#define LED4_PIN BIT7
#define LED4_PxOUT P1OUT
#define LED4_PxDIR P1DIR
#define LED4_PIN BIT1
#define HAL_LED1_ON() LED1_PxOUT |= LED1_PIN
#define HAL_LED2_ON() LED2_PxOUT |= LED2_PIN
......@@ -169,7 +171,7 @@ extern "C" {
#define RF_SPI_WAIT_MISO_LOW(x) st( uint8 count = 200; \
while(RF_PORT_IN & RF_SPI_MISO_PIN) \
{ \
__delay_cycles(5000); \
__delay_cycles(5000);\
count--; \
if (count == 0) break; \
} \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment