Other Parts Discussed in Thread: SIMPLICITI
ERROR
Error[Pe042]: operand types are incompatible ("enum smplStatus" and "uint8_t (*)(uint8_t)") C:\Users\pc\Desktop\eZ430\source_code\ti_demo\main.c 72
CODE
#include "bsp.h"
#include "mrfi.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "bsp_leds.h"
#include "bsp_buttons.h"
#include "vlo_rand.h"
#define BSP_Init()
#define SMPL_Init
#define SMPL_Link
#define SMPL_Send
#define SMPL_Ioctl
#define TI_getRandomIntegerFromVLO
void linkTo(void);
void MCU_Init(void);
__no_init volatile int tempOffset @ 0x10F4;
__no_init volatile char Flash_Addr[4] @ 0x10F0;
void createRandomAddress();
void main (void) { addr_t lAddr;
WDTCTL = WDTPW + WDTHOLD;
// Stop WDT
{
// delay loop to ensure proper startup before SimpliciTI increases DCO
// This is typically tailored to the power supply used, and in this case
// is overkill for safety due to wide distribution.
volatile int i;
for(i = 0; i < 0xFFFF; i++){}
}
if( CALBC1_8MHZ == 0xFF ) // Do not run if cal values are erased
{
volatile int i;
P1DIR |= 0x03;
BSP_TURN_ON_LED1();
BSP_TURN_OFF_LED2();
while(1)
{
for(i = 0; i < 0x5FFF; i++){}
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
}
} // SimpliciTI will change port pin settings as well
P1DIR = 0xFF;
P1OUT = 0x00;
P2DIR = 0x27;
P2OUT = 0x00;
P3DIR = 0xC0;
P3OUT = 0x00;
P4DIR = 0xFF;
P4OUT = 0x00;
BSP_Init();
if( Flash_Addr[0] == 0xFF &&
Flash_Addr[1] == 0xFF &&
Flash_Addr[2] == 0xFF &&
Flash_Addr[3] == 0xFF )
{
createRandomAddress();
// set Random device address at initial startup
}
lAddr.addr[0]=Flash_Addr[0];
lAddr.addr[1]=Flash_Addr[1];
lAddr.addr[2]=Flash_Addr[2];
lAddr.addr[3]=Flash_Addr[3];
SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
BCSCTL1 = CALBC1_8MHZ;
// Set DCO after random function
DCOCTL = CALDCO_8MHZ;
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
TACCTL0 = CCIE; // TACCR0 interrupt enabled
TACCR0 = 12000; // ~ 1 sec
TACTL = TASSEL_1 + MC_1; // ACLK, upmode // keep trying to join until successful. toggle LEDS to indicate that // joining has not occurred. LED3 is red but labeled LED 4 on the EXP // board silkscreen. LED1 is green.
while (SMPL_NO_JOIN == SMPL_Init((uint8_t (*)(linkID_t))0))
{
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();;
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
}
// unconditional link to AP which is listening due to successful join.
linkTo();
}
void createRandomAddress()
{
unsigned int rand, rand2;
do { rand = TI_getRandomIntegerFromVLO(0); // first byte can not be 0x00 of 0xFF
}
while( (rand & 0xFF00)==0xFF00 || (rand & 0xFF00)==0x0000 );
rand2 = TI_getRandomIntegerFromVLO(0);
BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator
FCTL3 = FWKEY + LOCKA; // Clear LOCK & LOCKA bits
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
Flash_Addr[0]=(rand>>8) & 0xFF;
Flash_Addr[1]=rand & 0xFF;
Flash_Addr[2]=(rand2>>8) & 0xFF;
Flash_Addr[3]=rand2 & 0xFF;
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit
}
void linkTo()
{
linkID_t linkID1; uint8_t msg[3];
// keep trying to link...
while (SMPL_SUCCESS != SMPL_Link(&linkID1))
{
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();
}
// Turn off all LEDs
if (BSP_LED1_IS_ON()) { BSP_TOGGLE_LED1();
}
if (BSP_LED2_IS_ON()) { BSP_TOGGLE_LED2();
}
while (1)
{
// This part of the program is greatly edited
// in order to display the output voltage
//volatile long temp;
int degC;
volatile long sample;
int voltage;
//signed int output; //output of the voltage on PIN 3
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, "" );
__bis_SR_register(LPM3_bits+GIE); // LPM3 with interrupts enabled
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, "" );
P2DIR |= 0x01; // OPEN PORT 2 and PIN 3 (PIN 3 = P2.1)
ADC10AE0 = 0x01; // Enabling Port for the ADC10
ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE + ADC10SR; //Intiaiting A to D conversion
ADC10CTL1 = INCH_0; //Enabling Channel A0
for( degC = 240; degC > 0; degC-- ); // delay to allow reference to settle
ADC10CTL0 |= ENC + ADC10SC; //sampling and conversion initiate
__bis_SR_register(CPUOFF + GIE); //LPM0 with interrupts enable
sample = ADC10MEM; // store binary results from ADC10MEM
ADC10CTL0 &= ~ENC; //
ADC10CTL0 &= ~(REFON + ADC10ON); // turn off A/D to save power
voltage = (sample*25)/51; //measuring average output voltage // the denominator value can be changed to amplify the voltage value
msg[0]=30; //this also can be assigned to 0 if the machine is washer. //Dryer is assigned with the value of 30.
msg[1]=0; //does not use in this program (from temperatuer demo program)
msg[2]=voltage; //store average output voltage
void linkTo(void);
void MCU_Init(void);
if (SMPL_SUCCESS == SMPL_Send(linkID1, msg, sizeof(msg)))
{
BSP_TOGGLE_LED2();
}
else
{
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
} }
}
/*------------------------------------------------------------------------------
* ADC10 interrupt service routine
------------------------------------------------------------------------------*/
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
/*------------------------------------------------------------------------------
* Timer A0 interrupt service routine
------------------------------------------------------------------------------*/
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
__bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bit from 0(SR)
}
ERROR
Error[Pe042]: operand types are incompatible ("enum smplStatus" and "uint8_t (*)(uint8_t)") C:\Users\pc\Desktop\eZ430\source_code\ti_demo\main.c 72