All mbed code for control over dive planes, pump motor, valve motor, BCUs, UART interface, etc.

Dependencies:   mbed ESC mbed MODDMA

Committer:
juansal12
Date:
Tue Jan 14 19:17:05 2020 +0000
Revision:
0:c3a329a5b05d
Sofi7 mbed code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
juansal12 0:c3a329a5b05d 1 // buttons.h
juansal12 0:c3a329a5b05d 2
juansal12 0:c3a329a5b05d 3 #ifndef BUTTONS_H
juansal12 0:c3a329a5b05d 4 #define BUTTONS_H
juansal12 0:c3a329a5b05d 5
juansal12 0:c3a329a5b05d 6 #include "mbed.h"
juansal12 0:c3a329a5b05d 7
juansal12 0:c3a329a5b05d 8 #define ADDR_BOARD_1 0x40
juansal12 0:c3a329a5b05d 9 #define ADDR_BOARD_2 0x40
juansal12 0:c3a329a5b05d 10
juansal12 0:c3a329a5b05d 11 #define BTTN_COUNT_BOARD_1 6
juansal12 0:c3a329a5b05d 12 #define BTTN_COUNT_BOARD_2 6
juansal12 0:c3a329a5b05d 13 #define BTTN_COUNT (BTTN_COUNT_BOARD_1 + BTTN_COUNT_BOARD_2)
juansal12 0:c3a329a5b05d 14
juansal12 0:c3a329a5b05d 15 class ButtonBoard
juansal12 0:c3a329a5b05d 16 {
juansal12 0:c3a329a5b05d 17 private:
juansal12 0:c3a329a5b05d 18 I2C _i2c;
juansal12 0:c3a329a5b05d 19 InterruptIn _int1;
juansal12 0:c3a329a5b05d 20 InterruptIn _int2;
juansal12 0:c3a329a5b05d 21
juansal12 0:c3a329a5b05d 22 char out_buf[8];
juansal12 0:c3a329a5b05d 23
juansal12 0:c3a329a5b05d 24 // Callback functions
juansal12 0:c3a329a5b05d 25 FunctionPointer _callback_table[BTTN_COUNT];
juansal12 0:c3a329a5b05d 26 bool _callback_table_valid[BTTN_COUNT];
juansal12 0:c3a329a5b05d 27 void (*_callbackFunction)(char buttonMask, bool pressed, char curState);
juansal12 0:c3a329a5b05d 28
juansal12 0:c3a329a5b05d 29 // Interrupt handlers
juansal12 0:c3a329a5b05d 30 void _int1_handler();
juansal12 0:c3a329a5b05d 31 void _int2_handler();
juansal12 0:c3a329a5b05d 32 void _fall_handler(char board);
juansal12 0:c3a329a5b05d 33
juansal12 0:c3a329a5b05d 34 // status
juansal12 0:c3a329a5b05d 35 volatile uint16_t _led_ports;
juansal12 0:c3a329a5b05d 36 volatile uint8_t _button_state;
juansal12 0:c3a329a5b05d 37
juansal12 0:c3a329a5b05d 38 public:
juansal12 0:c3a329a5b05d 39 ButtonBoard(PinName sda, PinName scl, PinName int1, PinName int2);
juansal12 0:c3a329a5b05d 40 ~ButtonBoard();
juansal12 0:c3a329a5b05d 41
juansal12 0:c3a329a5b05d 42 void registerCallback(uint32_t button, FunctionPointer p);
juansal12 0:c3a329a5b05d 43 void registerCallback(void (*p)(char buttonMask, bool pressed, char curState));
juansal12 0:c3a329a5b05d 44 //void setLED(uint32_t led, bool val);
juansal12 0:c3a329a5b05d 45 void setLEDs(char mask, bool turnOn, char board = ADDR_BOARD_1);
juansal12 0:c3a329a5b05d 46 char getLEDs(char ledMask, char board = ADDR_BOARD_1);
juansal12 0:c3a329a5b05d 47 char getButtons(char buttonMask, char board = ADDR_BOARD_1);
juansal12 0:c3a329a5b05d 48
juansal12 0:c3a329a5b05d 49
juansal12 0:c3a329a5b05d 50 //uint16_t readInputs();
juansal12 0:c3a329a5b05d 51 };
juansal12 0:c3a329a5b05d 52
juansal12 0:c3a329a5b05d 53 #endif