Browse Source

implement sync ping

a sync ping packet is sent when the clock enters sync mode.
this allows an ap program to sync the clock automaticly and exit the sync mode.
The sync ping packet is sent until any packet is received.
fertito
Daniel Poelzleithner 13 years ago
parent
commit
21bfd0134c
  1. 10
      TODO
  2. 6
      logic/rfsimpliciti.c
  3. 9
      logic/rfsimpliciti.h
  4. 34
      simpliciti/Applications/application/End_Device/main_ED_BM.c

10
TODO

@ -1,11 +1,17 @@
* modularise more code
* try to free more space
* autosync before/after flash
* use bulk transfer in sleep clock mode
* make buttons lock while sleep mode active
* better compilition depending on config file. someone with more make knowledge please ;-)
* fix warnings in simplicti code
* use RTC of the msp430 instead of the interrupt code
* fix the eggtimer. it runs to slow (like 2 seconds per second...)
* merge eggtimer into stopwatch. to much shared code that blow the firmware
== IN WORKS ==
* autosync before/after flash
== MAYBE ==
* use bulk transfer in sleep clock mode. There is now a multistep init phase that works quite well
=== DONE ===

6
logic/rfsimpliciti.c

@ -424,8 +424,8 @@ WDTCTL = WDTPW + WDTHOLD;
// send hw address so he recognices us and we will get a session id
simpliciti_data[0] = SIMPLICITI_PHASE_CLOCK_START_EVENTS;
simpliciti_data[1] = simpliciti_ed_address[0] ^ simpliciti_ed_address[1];
simpliciti_data[2] = simpliciti_ed_address[2] ^ simpliciti_ed_address[3];
// put 2 bytes of watch id into the package
WATCH_ID(simpliciti_data, 1);
// FIXME: TODO set program
simpliciti_data[3] = sPhase.program;
simpliciti_flag |= SIMPLICITI_TRIGGER_SEND_DATA | SIMPLICITI_TRIGGER_RECEIVE_DATA;
@ -436,7 +436,7 @@ WDTCTL = WDTPW + WDTHOLD;
//display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_ON);
// Wait for next sample
display_symbol(LCD_ICON_RECORD, SEG_ON);
Timer0_A4_Delay(CONV_MS_TO_TICKS(20));
Timer0_A4_Delay(CONV_MS_TO_TICKS(60));
// Read from sensor if DRDY pin indicates new data (set in PORT2 ISR)
if (request.flag.acceleration_measurement && ((AS_INT_IN & AS_INT_PIN) == AS_INT_PIN))
{

9
logic/rfsimpliciti.h

@ -82,6 +82,15 @@ typedef enum
#define SIMPLICITI_PHASE_CLOCK_EVENTS (0x03)
#define SIMPLICITI_PHASE_CLOCK_START_EVENTS (0x04)
// notify the ap that sync mode started
#define SIMPLICITI_SYNC_STARTED_EVENTS (0x10)
#define WATCH_ID(dst,offset) \
dst[offset] = simpliciti_ed_address[0] ^ simpliciti_ed_address[1];\
dst[offset+1] = simpliciti_ed_address[2] ^ simpliciti_ed_address[3];
#define SIMPLICITI_PHASE_CLOCK_START_RESPONSE (0x54)

34
simpliciti/Applications/application/End_Device/main_ED_BM.c

@ -36,6 +36,7 @@
#include "bsp_buttons.h"
#include "simpliciti.h"
#include "driver/display.h"
#include "rfsimpliciti.h"
// *************************************************************************************************
@ -304,18 +305,36 @@ void simpliciti_main_tx_only(void)
// *************************************************************************************************
void simpliciti_main_sync(void)
{
uint8_t len, i;
uint8_t ed_data[2];
uint8_t len, i, contacted;
uint8_t ed_data[4];
contacted = 0;
while(1)
{
// send a notification that we are in sync mode
if (!contacted) {
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
ed_data[0] = SIMPLICITI_SYNC_STARTED_EVENTS;
WATCH_ID(ed_data, 1);
ed_data[3] = 0x00;
SMPL_SendOpt(sLinkID1, ed_data, 4, SMPL_TXOPTION_NONE);
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);
}
// Sleep 0.5sec between ready-to-receive packets
// SimpliciTI has no low power delay function, so we have to use ours
Timer0_A4_Delay(CONV_MS_TO_TICKS(500));
// Get radio ready. Radio wakes up in IDLE state.
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
// send sync active package
ed_data[0] = SYNC_ED_TYPE_R2R;
ed_data[1] = 0xCB;
SMPL_SendOpt(sLinkID1, ed_data, 2, SMPL_TXOPTION_NONE);
// Send 2 byte long ready-to-receive packet to stimulate host reply
ed_data[0] = SYNC_ED_TYPE_R2R;
ed_data[1] = 0xCB;
@ -324,11 +343,12 @@ void simpliciti_main_sync(void)
// Wait shortly for host reply
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
NWK_DELAY(10);
// Check if a command packet was received
while (SMPL_Receive(sLinkID1, simpliciti_data, &len) == SMPL_SUCCESS)
{
// Decode received data
// Decode received data
contacted = 1;
if (len > 0)
{
// Use callback function in application to decode data and react

Loading…
Cancel
Save