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.
LTC2487/LTC2487.h@21:f87464a7e7c6, 2018-07-18 (annotated)
- Committer:
- jrodenburg
- Date:
- Wed Jul 18 21:28:45 2018 +0000
- Revision:
- 21:f87464a7e7c6
- Parent:
- 20:cdeed4dad690
Code with diagnostics
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jrodenburg | 0:a28a1035c31b | 1 | #include "mbed.h" |
| jrodenburg | 0:a28a1035c31b | 2 | |
| jrodenburg | 0:a28a1035c31b | 3 | class LTC2487 { |
| jrodenburg | 0:a28a1035c31b | 4 | public: |
| jrodenburg | 0:a28a1035c31b | 5 | |
| jrodenburg | 0:a28a1035c31b | 6 | /** Constructor |
| jrodenburg | 0:a28a1035c31b | 7 | * |
| jrodenburg | 0:a28a1035c31b | 8 | * @param sda I2C sda pin |
| jrodenburg | 0:a28a1035c31b | 9 | * @param scl I2C scl pin |
| jrodenburg | 0:a28a1035c31b | 10 | * @param address The hardware address of the LTC2487. This is the 3-bit |
| jrodenburg | 0:a28a1035c31b | 11 | * value that is physically set via A0, A1, and A2. |
| jrodenburg | 0:a28a1035c31b | 12 | * @param freq The I2C frequency. |
| jrodenburg | 0:a28a1035c31b | 13 | */ |
| jrodenburg | 0:a28a1035c31b | 14 | |
| jrodenburg | 0:a28a1035c31b | 15 | LTC2487(PinName sda, PinName scl, uint8_t address, int freq); |
| jrodenburg | 0:a28a1035c31b | 16 | |
| jrodenburg | 0:a28a1035c31b | 17 | |
| jrodenburg | 16:82d941b1ef21 | 18 | /** Write to LTC chip to select port to read from |
| jrodenburg | 0:a28a1035c31b | 19 | * |
| jrodenburg | 16:82d941b1ef21 | 20 | * This function is used select the LTC2487 channel we would like to read from |
| jrodenburg | 0:a28a1035c31b | 21 | * |
| jrodenburg | 16:82d941b1ef21 | 22 | * @param channel The channel we would like to read from |
| jrodenburg | 0:a28a1035c31b | 23 | */ |
| jrodenburg | 0:a28a1035c31b | 24 | |
| jrodenburg | 20:cdeed4dad690 | 25 | int writePort(int channel); |
| jrodenburg | 16:82d941b1ef21 | 26 | |
| jrodenburg | 16:82d941b1ef21 | 27 | /** Read value from LTC2487 |
| jrodenburg | 16:82d941b1ef21 | 28 | * |
| jrodenburg | 16:82d941b1ef21 | 29 | * This function is used to read data from LTC2487 from channel selected in writePort() |
| jrodenburg | 16:82d941b1ef21 | 30 | * |
| jrodenburg | 16:82d941b1ef21 | 31 | * @param N/A |
| jrodenburg | 16:82d941b1ef21 | 32 | */ |
| jrodenburg | 16:82d941b1ef21 | 33 | |
| jrodenburg | 16:82d941b1ef21 | 34 | float read(); |
| jrodenburg | 0:a28a1035c31b | 35 | |
| jrodenburg | 0:a28a1035c31b | 36 | /** Sets I2C address |
| jrodenburg | 0:a28a1035c31b | 37 | * |
| jrodenburg | 0:a28a1035c31b | 38 | * This function is used to set the I2C address |
| jrodenburg | 0:a28a1035c31b | 39 | * |
| jrodenburg | 0:a28a1035c31b | 40 | * @param address The I2C address |
| jrodenburg | 0:a28a1035c31b | 41 | */ |
| jrodenburg | 0:a28a1035c31b | 42 | |
| jrodenburg | 0:a28a1035c31b | 43 | void setAddress(int address); |
| jrodenburg | 0:a28a1035c31b | 44 | |
| jrodenburg | 0:a28a1035c31b | 45 | |
| jrodenburg | 0:a28a1035c31b | 46 | private: |
| jrodenburg | 0:a28a1035c31b | 47 | I2C i2c; |
| jrodenburg | 0:a28a1035c31b | 48 | uint8_t addrI2C; |
| jrodenburg | 0:a28a1035c31b | 49 | |
| jrodenburg | 0:a28a1035c31b | 50 | }; |
| jrodenburg | 0:a28a1035c31b | 51 |