David Wahl
/
Nucleo_BQ76PL536A
Initial rough copy
main.cpp@0:6e263c5ce85d, 2017-05-14 (annotated)
- Committer:
- dmwahl
- Date:
- Sun May 14 20:40:49 2017 +0000
- Revision:
- 0:6e263c5ce85d
- Child:
- 1:af7a249bd2b2
Basic class compiles
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dmwahl | 0:6e263c5ce85d | 1 | #include "mbed.h" |
dmwahl | 0:6e263c5ce85d | 2 | #include "bq76pl536a.h" |
dmwahl | 0:6e263c5ce85d | 3 | |
dmwahl | 0:6e263c5ce85d | 4 | // a SPI sub-class that provides a constructed default |
dmwahl | 0:6e263c5ce85d | 5 | class SPIPreInit : public SPI |
dmwahl | 0:6e263c5ce85d | 6 | { |
dmwahl | 0:6e263c5ce85d | 7 | public: |
dmwahl | 0:6e263c5ce85d | 8 | SPIPreInit(PinName mosi, PinName miso, PinName sclk, int freq, int bits, int mode) : SPI(mosi, miso, sclk) { |
dmwahl | 0:6e263c5ce85d | 9 | frequency(freq); |
dmwahl | 0:6e263c5ce85d | 10 | format(bits, mode); |
dmwahl | 0:6e263c5ce85d | 11 | //DigitalOut cs(ssel); |
dmwahl | 0:6e263c5ce85d | 12 | //cs = 1; |
dmwahl | 0:6e263c5ce85d | 13 | }; |
dmwahl | 0:6e263c5ce85d | 14 | }; |
dmwahl | 0:6e263c5ce85d | 15 | |
dmwahl | 0:6e263c5ce85d | 16 | SPIPreInit spi(D11, D12, D13, 1E6, 8, 1); |
dmwahl | 0:6e263c5ce85d | 17 | //SPI spi(D11, D12, D13); |
dmwahl | 0:6e263c5ce85d | 18 | |
dmwahl | 0:6e263c5ce85d | 19 | // (SPI object, PinName cs, u8t numDev, u8t attachedCells[], u16t cov[mV], u16t cuv[mV], u8t balanceTimeout[sec], bool balanceEnabled) |
dmwahl | 0:6e263c5ce85d | 20 | //const u8t attachedCells[2] = {5,5}; |
dmwahl | 0:6e263c5ce85d | 21 | //const u8t numDev = sizeof(attachedCells)/sizeof(attachedCells[0]); |
dmwahl | 0:6e263c5ce85d | 22 | |
dmwahl | 0:6e263c5ce85d | 23 | BQ76PL536A bq_pack(spi, D10, 1, 3500, 2700, 5, true); |
dmwahl | 0:6e263c5ce85d | 24 | //BQ76PL536A bq_pack(spi, D10); |
dmwahl | 0:6e263c5ce85d | 25 | //BQ76PL536A bq_pack(spi, D10); |
dmwahl | 0:6e263c5ce85d | 26 | |
dmwahl | 0:6e263c5ce85d | 27 | Serial pc(SERIAL_TX, SERIAL_RX); |
dmwahl | 0:6e263c5ce85d | 28 | |
dmwahl | 0:6e263c5ce85d | 29 | |
dmwahl | 0:6e263c5ce85d | 30 | int main() |
dmwahl | 0:6e263c5ce85d | 31 | { |
dmwahl | 0:6e263c5ce85d | 32 | |
dmwahl | 0:6e263c5ce85d | 33 | pc.baud(115200); |
dmwahl | 0:6e263c5ce85d | 34 | pc.printf("Started up\r\n"); |
dmwahl | 0:6e263c5ce85d | 35 | //pc.printf("COV: %u CUV: %u, numDev: %d\r\n", bq_pack.cov, bq_pack.cuv, bq_pack.numDev); |
dmwahl | 0:6e263c5ce85d | 36 | while(1) { |
dmwahl | 0:6e263c5ce85d | 37 | wait(1); |
dmwahl | 0:6e263c5ce85d | 38 | } |
dmwahl | 0:6e263c5ce85d | 39 | } |