Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Sean_AdiSense1000_V21 by
src/led.cpp@34:029fc3b83f78, 2018-09-24 (annotated)
- Committer:
- nfathurr
- Date:
- Mon Sep 24 11:39:35 2018 +0000
- Revision:
- 34:029fc3b83f78
v21
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nfathurr | 34:029fc3b83f78 | 1 | /* |
| nfathurr | 34:029fc3b83f78 | 2 | * led.c - control functions for led indicator |
| nfathurr | 34:029fc3b83f78 | 3 | * |
| nfathurr | 34:029fc3b83f78 | 4 | * Author: Jake Greaves |
| nfathurr | 34:029fc3b83f78 | 5 | */ |
| nfathurr | 34:029fc3b83f78 | 6 | |
| nfathurr | 34:029fc3b83f78 | 7 | #include "led.h" |
| nfathurr | 34:029fc3b83f78 | 8 | |
| nfathurr | 34:029fc3b83f78 | 9 | extern DigitalOut status_led; |
| nfathurr | 34:029fc3b83f78 | 10 | |
| nfathurr | 34:029fc3b83f78 | 11 | Ticker led_ticker; |
| nfathurr | 34:029fc3b83f78 | 12 | |
| nfathurr | 34:029fc3b83f78 | 13 | void Led_Blink( void ) { |
| nfathurr | 34:029fc3b83f78 | 14 | |
| nfathurr | 34:029fc3b83f78 | 15 | Led_On(!status_led); |
| nfathurr | 34:029fc3b83f78 | 16 | } |
| nfathurr | 34:029fc3b83f78 | 17 | |
| nfathurr | 34:029fc3b83f78 | 18 | void Led_Boot( void ) { |
| nfathurr | 34:029fc3b83f78 | 19 | |
| nfathurr | 34:029fc3b83f78 | 20 | // Attach interrupt to blink led |
| nfathurr | 34:029fc3b83f78 | 21 | led_ticker.attach(Led_Blink, LED_BLINK_PERIOD); |
| nfathurr | 34:029fc3b83f78 | 22 | } |
| nfathurr | 34:029fc3b83f78 | 23 | |
| nfathurr | 34:029fc3b83f78 | 24 | void Led_Idle( void ) { |
| nfathurr | 34:029fc3b83f78 | 25 | |
| nfathurr | 34:029fc3b83f78 | 26 | // Set led to constantly on |
| nfathurr | 34:029fc3b83f78 | 27 | led_ticker.detach(); |
| nfathurr | 34:029fc3b83f78 | 28 | Led_On(true); |
| nfathurr | 34:029fc3b83f78 | 29 | } |
| nfathurr | 34:029fc3b83f78 | 30 | |
| nfathurr | 34:029fc3b83f78 | 31 | void Led_On( bool_t state ) { |
| nfathurr | 34:029fc3b83f78 | 32 | |
| nfathurr | 34:029fc3b83f78 | 33 | // Set led state |
| nfathurr | 34:029fc3b83f78 | 34 | status_led = state; |
| nfathurr | 34:029fc3b83f78 | 35 | } |
| nfathurr | 34:029fc3b83f78 | 36 |
