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.
include/DigitalIn.h@1:1f2d9982fa8c, 2022-12-20 (annotated)
- Committer:
- hudakz
- Date:
- Tue Dec 20 12:08:07 2022 +0000
- Revision:
- 1:1f2d9982fa8c
mbed API for Raspberry Pi boards equipped with BCM2836 SoC.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| hudakz | 1:1f2d9982fa8c | 1 | #ifndef _DIGITAL_IN_H_ |
| hudakz | 1:1f2d9982fa8c | 2 | #define _DIGITAL_IN_H_ |
| hudakz | 1:1f2d9982fa8c | 3 | |
| hudakz | 1:1f2d9982fa8c | 4 | #include "BCM2835.h" |
| hudakz | 1:1f2d9982fa8c | 5 | |
| hudakz | 1:1f2d9982fa8c | 6 | class DigitalIn |
| hudakz | 1:1f2d9982fa8c | 7 | { |
| hudakz | 1:1f2d9982fa8c | 8 | public: |
| hudakz | 1:1f2d9982fa8c | 9 | DigitalIn(PinName pin) : |
| hudakz | 1:1f2d9982fa8c | 10 | gpio(pin) |
| hudakz | 1:1f2d9982fa8c | 11 | { |
| hudakz | 1:1f2d9982fa8c | 12 | gpio_dir(gpio, PIN_INPUT); |
| hudakz | 1:1f2d9982fa8c | 13 | gpio_write(gpio, LOW); |
| hudakz | 1:1f2d9982fa8c | 14 | } |
| hudakz | 1:1f2d9982fa8c | 15 | |
| hudakz | 1:1f2d9982fa8c | 16 | DigitalIn(PinName pin, PinMode mode) : |
| hudakz | 1:1f2d9982fa8c | 17 | gpio(pin) |
| hudakz | 1:1f2d9982fa8c | 18 | { |
| hudakz | 1:1f2d9982fa8c | 19 | gpio_dir(gpio, PIN_INPUT); |
| hudakz | 1:1f2d9982fa8c | 20 | gpio_mode(pin, mode); |
| hudakz | 1:1f2d9982fa8c | 21 | } |
| hudakz | 1:1f2d9982fa8c | 22 | |
| hudakz | 1:1f2d9982fa8c | 23 | int read() { return gpio_read(gpio); } |
| hudakz | 1:1f2d9982fa8c | 24 | void mode(PinMode mode) { mode == PullUp ? gpio_write(gpio, HIGH) : gpio_write(gpio, LOW); } |
| hudakz | 1:1f2d9982fa8c | 25 | void attach(FunctionPointer fptr, Digivalue m) { attachInterrupt(gpio, fptr, m); } |
| hudakz | 1:1f2d9982fa8c | 26 | operator int() { return read(); } |
| hudakz | 1:1f2d9982fa8c | 27 | protected: |
| hudakz | 1:1f2d9982fa8c | 28 | PinName gpio; |
| hudakz | 1:1f2d9982fa8c | 29 | }; |
| hudakz | 1:1f2d9982fa8c | 30 | |
| hudakz | 1:1f2d9982fa8c | 31 | #endif // _DIGITAL_IN_H_ |
| hudakz | 1:1f2d9982fa8c | 32 |