TOOTHPIC RF Solutions, TOOTHPIC Datasheet - Page 114

MODULE, BLUETOOTH, DATA ACQUISITION

TOOTHPIC

Manufacturer Part Number
TOOTHPIC
Description
MODULE, BLUETOOTH, DATA ACQUISITION
Manufacturer
RF Solutions
Datasheet

Specifications of TOOTHPIC

Svhc
No SVHC (15-Dec-2010)
Semaphores
Only one high-priority and one low-priority interrupt can be serviced at a time. If you try to do something from
within an interrupt service routine which relies on an interrupt of the same or lower level being responded to,
the processor will hang because the second interrupt call will never be serviced.
Callbacks generally occur from within a low priority interrupt, and this is where you are most likely to
encounter this problem. You can’t do anything inside a callback function which relies on low priority interrupts
being responded to. This includes functions such as AwaitBMTOK, which require interpretation of incoming
serial data from BlueMatik. It does not include most BMTCommands and FxPCommands which transmit data
only. (The exception is BMTReset, which cannot be called from within a callback.)
The solution is to use Semaphores. A semaphore is a global variable which you set inside the interrupt
service routine before promptly returning from interrupt. From inside your main code, inspect the semaphore
value frequently and respond appropriately when it is set.
In addition to your own semaphores, ToothPIC OS provides certain semaphores which it uses to
communicate the current state of the ToothPIC OS. You may inspect these logical values but you should not
modify them except by calling ClearSemaphores in when initializing BlueMatik. The semaphores and
macros are defined in ToothPIC.h.
The following example puts BlueMatik into slave mode when two semaphores are raised: the
BlueMatikInitOK ToothPIC semaphore and a developer-defined StartSlave semaphore which is raised
on initialization and whenever a master disconnects.
Bool StartSlave = True;
void main( void )
{
Page 114
while ( 1 )
{
ResetOrWakeEventWasStackOverflow
ResetOrWakeEventWasStackUnderflow
ResetOrWakeEventWasSoftwareReset
ResetOrWakeEventWasInterrtuptOrNMCLRDuringSleep
ResetOrWakeEventWasWDTReset
ResetOrWakeEventWasWDTWakeup
ResetOrWakeEventWasBrownOut
if (BlueMatikInitOK && StartSlave)
{
9-Apr-06
Semaphore / Macro
BlueMatikExists
ProcessingATCommand
AwaitInitOK
AwaitBMTOK
IsConnected
InFxPMode
FxPDeviceConnected
IsFxPInitialized
BMTCommand( BMTC_Slave, 0, 0 );
AwaitConnect(0);
Toothpick 3.0.00007
DS380-8
Function
BlueMatik module is attached and has completed initialization.
BlueMatik is still processing an AT function
Waits until BlueMatikInitOK is set
Waits until ProcessingATCommand is clear
Raised while remote device is connected to BlueMatik
Raised while FlexiPanel user interface service is operating
Raised while FlexiPanel compatible is connected
Raised once FlexiPanel control data has been initialized and
is valid
© FlexiPanel Ltd
Patents apply and/or pending
// Semaphore
// Test semaphores
// Go into slave mode
www.FlexiPanel.com

Related parts for TOOTHPIC