This project serves as a template for work with the Freescale FRDM-KL46 board. Support will be added to all on-board peripherals, sensors and I/O.
Dependencies: FRDM_MMA8451Q MAG3110 TSI mbed
Project Information:
Theory
This project has been created to serve as a template for those who wish to use the Freescale Freedom FRDM-KL46Z board. Existing drivers within mbed have been brought together and board specific configurations for certain inputs and outputs have included.
Libraries
- TSI (source: http://mbed.org/users/emilmont/code/TSI/ ) Capacitive Touch library to support the on-board Touch-Slider
- FRDM_MMA8451Q (source: http://mbed.org/users/clemente/code/FRDM_MMA8451Q/ ) Freescale MMA8451 Accelerometer connected on I2C0
- MAG3110 (source: http://mbed.org/users/mmaas/code/MAG3110/) (based on: http://mbed.org/users/SomeRandomBloke/code/MAG3110/)
TODOs
- Add support for Segment LCD - intend to use driver in example code: http://cache.freescale.com/files/32bit/software/KL46_SC.exe
Hardware Information:
FRDM-KL46Z Information
- User Guide Guide: http://cache.freescale.com/files/microcontrollers/doc/user_guide/FRDM-KL46Z_UM.pdf
- Schematics: http://cache.freescale.com/files/microcontrollers/hardware_tools/schematics/FRDM-KL46Z_SCH.pdf
Freescale Kinetis L-Series Microcontroller Information
- Kinetis KL46 Drop Page: http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KL4x
- Kinetis KL46 Fact Sheet: http://cache.freescale.com/files/microcontrollers/doc/fact_sheet/LSERIESKL4FS.pdf
- Kinetis KL46 Reference Manual: http://cache.freescale.com/files/microcontrollers/doc/ref_manual/KL46P121M48SF4RM.pdf
- Kinetis KL46 Data Sheet: http://cache.freescale.com/files/microcontrollers/doc/data_sheet/KL46P121M48SF4.pdf
Freescale Sensor Information
MMA8451Q
MAG3110
Diff: main.cpp
- Revision:
- 8:b61a953b6128
- Parent:
- 7:9e1d22b35dab
diff -r 9e1d22b35dab -r b61a953b6128 main.cpp --- a/main.cpp Sat Jan 04 04:40:00 2014 +0000 +++ b/main.cpp Sat Jan 04 05:54:25 2014 +0000 @@ -89,6 +89,12 @@ ///////////////////////////////////////////////////////////////////// +// Include a 1 second ticker as a heartbeat +Ticker heartBeat; + + + +///////////////////////////////////////////////////////////////////// // Structure to hold FRDM-KL46Z sensor and input data struct KL46_SENSOR_DATA { int sw1State; @@ -114,12 +120,21 @@ ///////////////////////////////////////////////////////////////////// +// Prototype for LED flash routine +void ledFlashTick(void); + + +///////////////////////////////////////////////////////////////////// // main application int main() { // Ensure LEDs are off greenLED = LED_OFF; redLED = LED_OFF; + + // Set up heartBeat Ticker to flash an LED + heartBeat.attach(&ledFlashTick, 1.0); + // Set Serial Port data rate and say Hello pc.baud( 115200 ); @@ -158,14 +173,10 @@ serialSendSensorData(); - // Blink LEDs (show life) + // Blink red LED (loop running) redLED = LED_ON; wait(.03); - greenLED = LED_ON; - wait(.03); redLED = LED_OFF; - wait(.03); - greenLED = LED_OFF; wait(1); } @@ -185,4 +196,8 @@ } +void ledFlashTick(void) +{ + greenLED = !greenLED; +}