jadeku.c File Reference

JADEKU Portable ADQ device for Routines Control. More...

#include <app.h>
Include dependency graph for jadeku.c:

Go to the source code of this file.

Macros

#define _USESLEEP   1
 
#define OUTBUFSIZE   20
 
#define INBUFSIZE   20
 
#define WLONG   100
 Wait long time. More...
 
#define WSHORT   25
 Wait short time. More...
 
#define BLONG   2000
 Beep long time. More...
 
#define BSHORT   1000
 Beep short time. More...
 
#define beep(time)   piezo(18,time)
 

Functions

static BYTE SearchbyID (WORD id)
 
static BYTE Save (WORD id)
 
static void Process (void)
 
static BYTE CRO_Crc (volatile BYTE *data, BYTE size)
 
static void SendRegis (void)
 
static VOID xitoa (WORD n, BYTE *s, BYTE pad)
 
static VOID xreverse (BYTE *s)
 
static void InitialState (void)
 
static void DoOK (void)
 
static void DoError (void)
 
static BYTE ccp (BYTE idx)
 
static void InitPacket (BYTE cmd)
 
static void Add (BYTE num)
 
static void Init0 (void)
 
static void Init1 (void)
 
static void SendInfo (void)
 
static void SendFlash (void)
 
static void SetTime (BYTE dir)
 
static void CheckUnits (WORD id)
 
void setports (void)
 
static void piezo (BYTE t, WORD d)
 
static void interrupt isr (void)
 
void TestBat (void)
 
void main (void)
 

Variables

volatile BYTE gFlags =0x00
 
static bank1 WORD gIbut
 Current touch read. More...
 
static bank1 WORD gTbut
 antiping touch read More...
 
static bank1 BYTE gBuf [10]
 general buffer More...
 
static bank2 BYTE gIdx
 index to build packets More...
 
static volatile bank1 time_t gTimeout =0
 Protocol Timeout. More...
 
static volatile bank2 BYTE gRetry =0
 Retry count. More...
 
volatile bank1 time_t TIME =0
 Timer in unix format. More...
 
volatile bank1 BYTE gOut [20]
 Output buffer. More...
 
volatile bank1 BYTE gIn [20]
 Input buffer. More...
 
volatile bank2 BYTE gTXCount =0
 Output buffer index. More...
 
volatile bank2 BYTE gRXCount =0
 Input buffer index. More...
 
volatile bank2 BYTE gByte ='A'
 Input byte. More...
 
volatile bank2 BYTE gError =0x00
 Error flag state. More...
 
volatile bank2 BYTE gSleepTime
 Count to sleep. More...
 
volatile BYTE gSleep =0
 Sleep mode enable. More...
 
volatile bank2 time_t gTampTime
 Tamper loop time. More...
 
volatile bank2 BYTE gState =FM_IDLE
 Protocol Receiver state machine. More...
 
volatile bank2 BYTE gCrc =0
 Protocol Checksum. More...
 

Detailed Description

JADEKU Portable ADQ device for Routines Control.

Copyright (C) 2006-2009, Hernan Monserrat hemonserrat<at>gmail<dot>com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Note
Platform ADQ128 V2 Embedded Board. HT-PIC V8.05PL2

Definition in file jadeku.c.

Macro Definition Documentation

◆ _USESLEEP

#define _USESLEEP   1

configuration bits: OSC: XT
WDTE: DISABLE
PWRTE: DISABLE
BODEN: DISABLE
LVP: HV DISABLE
CPD: PROTECTED
WRT: NO EECON
DEBUG: DISABLE
CP1|CP0: OFF

Definition at line 50 of file jadeku.c.

◆ beep

#define beep (   time)    piezo(18,time)

Activates the beeper and green led for a lapsed time.

Parameters
time- number of milliseconds to sound.

Definition at line 192 of file jadeku.c.

◆ BLONG

#define BLONG   2000

Beep long time.

Definition at line 113 of file jadeku.c.

◆ BSHORT

#define BSHORT   1000

Beep short time.

Definition at line 114 of file jadeku.c.

◆ INBUFSIZE

#define INBUFSIZE   20

Definition at line 94 of file jadeku.c.

◆ OUTBUFSIZE

#define OUTBUFSIZE   20

Definition at line 92 of file jadeku.c.

◆ WLONG

#define WLONG   100

Wait long time.

Definition at line 111 of file jadeku.c.

◆ WSHORT

#define WSHORT   25

Wait short time.

Definition at line 112 of file jadeku.c.

Function Documentation

◆ Add()

static void Add ( BYTE  num)
static

Converts a byte number into its ASCII representation and store it in the outgoing buffer.

Parameters
num- byte to convert and store.

Definition at line 579 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ccp()

static BYTE ccp ( BYTE  idx)
static

Converts an ASCII to its byte representation from the input buffer SCI.

Parameters
idx- offset into the input buffer
Returns
byte conversion of the ASCII value in the buffer.

Definition at line 555 of file jadeku.c.

Here is the caller graph for this function:

◆ CheckUnits()

static void CheckUnits ( WORD  id)
static

Looks for ID storage hole, decides modify or append

Parameters
id- Identification to find

Definition at line 783 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CRO_Crc()

static BYTE CRO_Crc ( volatile BYTE data,
BYTE  size 
)
static

Compute CRC

Parameters
data- buffer to compute size - number of bytes to compute
Returns
CRC calculated.

Definition at line 960 of file jadeku.c.

Here is the caller graph for this function:

◆ DoError()

static void DoError ( void  )
static

Sets the error indicator in the LED (red)

Definition at line 246 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoOK()

static void DoOK ( void  )
static

If all is ok beep and show green status on the LED. if battery low tilt.

Definition at line 221 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init0()

static void Init0 ( void  )
static

Send initialization info 2

Definition at line 589 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init1()

static void Init1 ( void  )
static

Send Initialization info 1

Parameters
regis- number of available registrations to download.

Definition at line 619 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitialState()

static void InitialState ( void  )
static

Sets initilization status and variables for the CPU and systems.

Definition at line 136 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitPacket()

static void InitPacket ( BYTE  cmd)
static

Initilize the outgoing buffer with the command to be send

Parameters
cmd- command to be send

Definition at line 567 of file jadeku.c.

Here is the caller graph for this function:

◆ isr()

static void interrupt isr ( void  )
static

Interrupt service routine: services: SCI, SPI, RTC, I/Os

Definition at line 268 of file jadeku.c.

Here is the call graph for this function:

◆ main()

void main ( void  )

Start entry point. Polling loop.

Definition at line 423 of file jadeku.c.

Here is the call graph for this function:

◆ piezo()

static void piezo ( BYTE  t,
WORD  d 
)
static

Definition at line 194 of file jadeku.c.

Here is the call graph for this function:

◆ Process()

static void Process ( void  )
static

Process incoming packets from SCI

Definition at line 831 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Save()

static BYTE Save ( WORD  id)
static

Store adquisition data to DB

Parameters
id- Identification acquired
Returns
TRUE

Definition at line 900 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SearchbyID()

static BYTE SearchbyID ( WORD  id)
static

Local Function Prototypes

Search DB by ID

Parameters
id- Identification to find
Returns
TRUE found enable or not found but permitted FALSE not found

Definition at line 934 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendFlash()

static void SendFlash ( void  )
static

Retrieve Flash sectors and send it to host.

Definition at line 689 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendInfo()

static void SendInfo ( void  )
static

Send information to the host

Definition at line 725 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendRegis()

static void SendRegis ( void  )
static

Retrieve next record from REGIS DB and send it to host.

Definition at line 651 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setports()

void setports ( void  )

Sets ports for low power sleep mode.

Definition at line 120 of file jadeku.c.

Here is the caller graph for this function:

◆ SetTime()

static void SetTime ( BYTE  dir)
static

Real time clock preset routines

Parameters
dir- initial mode: 1 extract from packet 0 default 12:00:00 01/01/2002

Definition at line 753 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestBat()

void TestBat ( void  )

Battery Level Monitor

Definition at line 386 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xitoa()

static VOID xitoa ( WORD  n,
BYTE s,
BYTE  pad 
)
static

converts an integer to an ASCII string representation

Parameters
n- number to be converted s - Buffer to store result pad - right alignment padding
Returns
TRUE on packet received, FALSE timeout.
Remarks
feed gCpos and gCtime with the received data.

Definition at line 980 of file jadeku.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xreverse()

static VOID xreverse ( BYTE s)
static

reverse the contents of string s

Parameters
s- NULL terminated string

Definition at line 997 of file jadeku.c.

Here is the caller graph for this function:

Variable Documentation

◆ gBuf

bank1 BYTE gBuf[10]
static

general buffer

Definition at line 85 of file jadeku.c.

◆ gByte

volatile bank2 BYTE gByte ='A'

Input byte.

Definition at line 98 of file jadeku.c.

◆ gCrc

volatile bank2 BYTE gCrc =0

Protocol Checksum.

Definition at line 108 of file jadeku.c.

◆ gError

volatile bank2 BYTE gError =0x00

Error flag state.

Definition at line 99 of file jadeku.c.

◆ gFlags

volatile BYTE gFlags =0x00

Variables

Definition at line 81 of file jadeku.c.

◆ gIbut

bank1 WORD gIbut
static

Current touch read.

Definition at line 83 of file jadeku.c.

◆ gIdx

bank2 BYTE gIdx
static

index to build packets

Definition at line 86 of file jadeku.c.

◆ gIn

volatile bank1 BYTE gIn[20]

Input buffer.

Definition at line 95 of file jadeku.c.

◆ gOut

volatile bank1 BYTE gOut[20]

Output buffer.

Definition at line 93 of file jadeku.c.

◆ gRetry

volatile bank2 BYTE gRetry =0
static

Retry count.

Definition at line 89 of file jadeku.c.

◆ gRXCount

volatile bank2 BYTE gRXCount =0

Input buffer index.

Definition at line 97 of file jadeku.c.

◆ gSleep

volatile BYTE gSleep =0

Sleep mode enable.

Definition at line 103 of file jadeku.c.

◆ gSleepTime

volatile bank2 BYTE gSleepTime

Count to sleep.

Definition at line 102 of file jadeku.c.

◆ gState

volatile bank2 BYTE gState =FM_IDLE

Protocol Receiver state machine.

Definition at line 107 of file jadeku.c.

◆ gTampTime

volatile bank2 time_t gTampTime

Tamper loop time.

Definition at line 106 of file jadeku.c.

◆ gTbut

bank1 WORD gTbut
static

antiping touch read

Definition at line 84 of file jadeku.c.

◆ gTimeout

volatile bank1 time_t gTimeout =0
static

Protocol Timeout.

Definition at line 88 of file jadeku.c.

◆ gTXCount

volatile bank2 BYTE gTXCount =0

Output buffer index.

Definition at line 96 of file jadeku.c.

◆ TIME

volatile bank1 time_t TIME =0

Timer in unix format.

Definition at line 91 of file jadeku.c.