mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 02:42:33 +00:00
recover annotations from b25b31c2
This commit is contained in:
parent
8ca565ce9c
commit
a3683d7720
@ -36,11 +36,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
//
|
/* EXAMPLE_START(led_counter): UART and timer interrupt without Bluetooth
|
||||||
// led_counter demo - uses the BTstack run loop to blink an LED
|
*
|
||||||
//
|
* @text The example uses the BTstack run loop to blink an LED.
|
||||||
|
* The example demonstrates how to setup hardware, initialize BTstack without
|
||||||
|
* Bluetooth, provide a periodic timer to toggle an LED and print number of
|
||||||
|
* toggles as a minimal BTstack test.
|
||||||
|
*/
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@ -57,6 +63,15 @@ static void run_loop_register_timer(timer_source_t *timer, uint16_t period){
|
|||||||
run_loop_add_timer(timer);
|
run_loop_add_timer(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* @section Periodic Timer Setup
|
||||||
|
*
|
||||||
|
* @text As timers in BTstack are single shot,
|
||||||
|
* the periodic counter is implemented by re-registering the timer source in the
|
||||||
|
* heartbeat handler callback function. Listing LEDToggler shows heartbeat handler
|
||||||
|
* adapted to periodically toggle an LED and print number of toggles.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* LISTING_START(LEDToggler): Periodic counter */
|
||||||
static void heartbeat_handler(timer_source_t *ts){
|
static void heartbeat_handler(timer_source_t *ts){
|
||||||
// increment counter
|
// increment counter
|
||||||
char lineBuffer[30];
|
char lineBuffer[30];
|
||||||
@ -69,20 +84,24 @@ static void heartbeat_handler(timer_source_t *ts){
|
|||||||
// re-register timer
|
// re-register timer
|
||||||
run_loop_register_timer(ts, HEARTBEAT_PERIOD_MS);
|
run_loop_register_timer(ts, HEARTBEAT_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
/* LISTING_END */
|
||||||
|
|
||||||
static void timer_setup(){
|
/* @section Turn On and Go
|
||||||
|
*
|
||||||
|
* @text Listing MainConfiguration shows main application code.
|
||||||
|
* It is called after hardware and BTstack configuration (memory, run loop and
|
||||||
|
* transport layer) by the platform main in
|
||||||
|
* \path{platforms/PLATFORM/src/main.c}.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* LISTING_START(MainConfiguration): Setup heartbeat timer */
|
||||||
|
int btstack_main(int argc, const char * argv[]);
|
||||||
|
int btstack_main(int argc, const char * argv[]){
|
||||||
// set one-shot timer
|
// set one-shot timer
|
||||||
heartbeat.process = &heartbeat_handler;
|
heartbeat.process = &heartbeat_handler;
|
||||||
run_loop_register_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
|
run_loop_register_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
|
||||||
}
|
|
||||||
|
|
||||||
int btstack_main(int argc, const char * argv[]);
|
|
||||||
int btstack_main(int argc, const char * argv[]){
|
|
||||||
|
|
||||||
timer_setup();
|
|
||||||
|
|
||||||
printf("Run...\n\r");
|
printf("Run...\n\r");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/* LISTING_END */
|
||||||
|
/* EXAMPLE_END */
|
Loading…
x
Reference in New Issue
Block a user