Download BL620 smartBASIC extensions v12.4.10.0
Transcript
smart BASIC – BL620 Extension Functionality User Manual FUNCTION HndlrBtn0Pr() AS INTEGER //just exit and stop waiting for events ENDFUNC 0 ONEVENT ONEVENT EVBLEMSG CALL HandlerBleMsg EVGPIOCHAN1 CALL HndlrBtn0Pr rc=GpioBindEvent(1,16,1) //Channel 1, bind to low transition on GPIO pin 16 PRINT "\nSupply voltage is "; ReadPwrSupplyMv();"mV\n" mv=2700 rc=SetPwrSupplyThreshMv(mv) PRINT "\nWaiting for power supply to fall below ";mv;"mV" //wait for events and messages WAITEVENT PRINT "\nExiting..." Expected Output: Supply voltage is 3343mV Waiting for power supply to fall below 2700mV Exiting... SETPWRSUPPLYTHRESHMV is an extension function. 7. EVENTS AND MESSAGES smart BASIC is designed to be event driven, which makes it suitable for embedded platforms where it is normal to wait for something to happen and then respond. To ensure that access to variables and resources ends up in race conditions, the event handling is done synchronously, meaning the smart BASIC runtime engine has to process a WAITEVENT statement for any events or messages to be processed. This guarantees that smart BASIC will never need the complexity of locking variables and objects. There are many subsystems which generate events and messages as follows: Timer events, which generate timer expiry events and are described here. Messages thrown from within the user’s BASIC application as described here. Events related to the UART interface as described here. GPIO input level change events as described here. BLE events and messages as described here. Generic Characteristics events and messages as described here. Embedded Wireless Solutions Support Center: http://ews-support.lairdtech.com www.lairdtech.com/wireless 200 Laird Technologies Americas: +1-800-492-2320 Europe: +44-1628-858-940 Hong Kong: +852-2268-6567 x026