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.
Dependencies: mbed ESC mbed MODDMA
ButtonBoard.h
00001 // buttons.h 00002 00003 #ifndef BUTTONS_H 00004 #define BUTTONS_H 00005 00006 #include "mbed.h" 00007 00008 #define ADDR_BOARD_1 0x40 00009 #define ADDR_BOARD_2 0x40 00010 00011 #define BTTN_COUNT_BOARD_1 6 00012 #define BTTN_COUNT_BOARD_2 6 00013 #define BTTN_COUNT (BTTN_COUNT_BOARD_1 + BTTN_COUNT_BOARD_2) 00014 00015 class ButtonBoard 00016 { 00017 private: 00018 I2C _i2c; 00019 InterruptIn _int1; 00020 InterruptIn _int2; 00021 00022 char out_buf[8]; 00023 00024 // Callback functions 00025 FunctionPointer _callback_table[BTTN_COUNT]; 00026 bool _callback_table_valid[BTTN_COUNT]; 00027 void (*_callbackFunction)(char buttonMask, bool pressed, char curState); 00028 00029 // Interrupt handlers 00030 void _int1_handler(); 00031 void _int2_handler(); 00032 void _fall_handler(char board); 00033 00034 // status 00035 volatile uint16_t _led_ports; 00036 volatile uint8_t _button_state; 00037 00038 public: 00039 ButtonBoard(PinName sda, PinName scl, PinName int1, PinName int2); 00040 ~ButtonBoard(); 00041 00042 void registerCallback(uint32_t button, FunctionPointer p); 00043 void registerCallback(void (*p)(char buttonMask, bool pressed, char curState)); 00044 //void setLED(uint32_t led, bool val); 00045 void setLEDs(char mask, bool turnOn, char board = ADDR_BOARD_1); 00046 char getLEDs(char ledMask, char board = ADDR_BOARD_1); 00047 char getButtons(char buttonMask, char board = ADDR_BOARD_1); 00048 00049 00050 //uint16_t readInputs(); 00051 }; 00052 00053 #endif
Generated on Wed Jul 13 2022 13:43:34 by
