Library for Modtronix NZ32 STM32 boards, like the NZ32-SC151, NZ32-SB072, NZ32-SE411 and others
Diff: nz32s.h
- Revision:
- 5:e1297df8ee0d
- Parent:
- 3:99cb87ee1792
- Child:
- 7:709130701ac7
--- a/nz32s.h Sun Aug 30 09:29:08 2015 +1000 +++ b/nz32s.h Sun Aug 30 11:59:06 2015 +1000 @@ -1,5 +1,5 @@ /** - * File: modtronix_nz32s.h + * File: nz32s.h * * Author: Modtronix Engineering - www.modtronix.com * @@ -18,10 +18,15 @@ * COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ -#ifndef MODTRONIX_NZ32S_H_ -#define MODTRONIX_NZ32S_H_ +#ifndef NZ32S_H_ +#define NZ32S_H_ #include "mbed.h" +#include "nz32s_default_config.h" + +#ifdef __cplusplus +extern "C" { +#endif #ifndef WEAK #if defined (__ICCARM__) @@ -34,9 +39,68 @@ class NZ32S { public: - static IWDG_HandleTypeDef hiwdg; //Watchdog Timer + /** Toggle System LED1 + */ + static inline void toggle_led1(void) { + led1 = !led1; + } + + /** Set System LED1 + */ + static inline void set_led1(void) { + led1 = 1; + } + + /** Set System LED1 + */ + static inline void clear_led1(void) { + led1 = 0; + } + + /** Set System LED1 + */ + static inline void write_led1(bool val) { + led1 = val; + } + + + /** Get state of button1 + */ + static inline bool get_btn1(void) { + return (bool)btn1.read(); + } -public: + /** Enable fast charging + * This function will enable fast charging of the battery. Ensure solder jumper labeled + * "Fast Charge" (J13 on NZ32-SC151) on the back of the board is made! + */ + static inline void enable_fast_charging(void) { + #if (DONT_USE_A13_A14 == 0) + asdf + enableFastCharge.output(); + enableFastCharge = 0; + #endif + } + + + /** Disable fast charging + */ + static inline void disable_fast_charging(void) { + #if (DONT_USE_A13_A14 == 0) + NZ32S::enableFastCharge.input(); + NZ32S::enableFastCharge.mode(PullNone); + #endif + } + + /** Get the battery voltage. + */ + static uint16_t get_batt_mv(); + + /** + * Get Vusb or 5V supply voltage in millivolts. + */ + static uint16_t get_supply_mv(void); + /** * Reset I2C bus */ @@ -104,8 +168,18 @@ */ static inline void print_reset_cause(bool clearFlags); +public: + static IWDG_HandleTypeDef hiwdg; //Watchdog Timer + static DigitalOut led1; + static DigitalIn btn1; +#if (DONT_USE_A13_A14 == 0) + static DigitalInOut enableFastCharge; +#endif }; +#ifdef __cplusplus +}; +#endif -#endif //MODTRONIX_NZ32S_H_ +#endif //NZ32S_H_