
MAX20361 Demo with LoRa Module on LP0 mode
Dependencies: SX1276GenericLib USBDevice
Fork of NonPingPong_PICO_LoRa_LP0 by
AO19Lib/AO19_lib.h@7:c0872971aef4, 2020-10-16 (annotated)
- Committer:
- walterluu
- Date:
- Fri Oct 16 06:50:42 2020 +0000
- Revision:
- 7:c0872971aef4
- Parent:
- 6:51f492ca61a2
MAX20361 Demo with LoRa Module on LP0 mode
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
walterluu | 6:51f492ca61a2 | 1 | #include "mbed.h" |
walterluu | 6:51f492ca61a2 | 2 | |
walterluu | 6:51f492ca61a2 | 3 | //AO19 Registers |
walterluu | 6:51f492ca61a2 | 4 | #define AO19_DEVICE_ID 0x00 // AO19 Chip ID |
walterluu | 6:51f492ca61a2 | 5 | #define AO19_BB_CFG0 0x01 // AO19 Buck Boost Configure |
walterluu | 6:51f492ca61a2 | 6 | #define AO19_BB_VSET 0x02 // AO19 Buck Boost Voltage Set |
walterluu | 6:51f492ca61a2 | 7 | #define AO19_BB_ISET 0x03 // AO19 Buck Boost Current Set |
walterluu | 6:51f492ca61a2 | 8 | #define AO19_BB_CFG1 0x04 // AO19 Buck Boost Configure 1 |
walterluu | 6:51f492ca61a2 | 9 | #define AO19_STATUS 0x05 // AO19 Status Register |
walterluu | 6:51f492ca61a2 | 10 | #define AO19_INT 0x06 // AO19 Interrupt |
walterluu | 6:51f492ca61a2 | 11 | #define AO19_MSK 0x07 // AO19 Mask |
walterluu | 6:51f492ca61a2 | 12 | #define AO19_LOCK_MSK 0x50 // AO19 Lock Mask |
walterluu | 6:51f492ca61a2 | 13 | #define AO19_PASSWD 0x51 // AO19 Password |
walterluu | 6:51f492ca61a2 | 14 | |
walterluu | 6:51f492ca61a2 | 15 | #define DEVICE_ACK 0 |
walterluu | 6:51f492ca61a2 | 16 | #define DEVICE_NACK 1 |
walterluu | 6:51f492ca61a2 | 17 | #define DEVICE_BAD_RESP 2 |
walterluu | 6:51f492ca61a2 | 18 | |
walterluu | 6:51f492ca61a2 | 19 | #define MAX_DEVICES 64 // Maximum number of rom devices allowed |
walterluu | 6:51f492ca61a2 | 20 | #define ID_LENGTH 6 // Rom ID length in bytes |
walterluu | 6:51f492ca61a2 | 21 | |
walterluu | 6:51f492ca61a2 | 22 | struct AO19_struct { |
walterluu | 6:51f492ca61a2 | 23 | char rom_id[ID_LENGTH]; // device ROM ID |
walterluu | 6:51f492ca61a2 | 24 | char I2C_address; // I2C addess, based on GPIO0 and GPIO1 at power up |
walterluu | 6:51f492ca61a2 | 25 | // Why char? |
walterluu | 6:51f492ca61a2 | 26 | }; |
walterluu | 6:51f492ca61a2 | 27 | |
walterluu | 6:51f492ca61a2 | 28 | // ***************************************************************************** |
walterluu | 6:51f492ca61a2 | 29 | // AO19_write_register(char, char, char) writes single byte to AO19 |
walterluu | 6:51f492ca61a2 | 30 | // char I2C address |
walterluu | 6:51f492ca61a2 | 31 | // char AO19 register address |
walterluu | 6:51f492ca61a2 | 32 | // char data byte to be writen |
walterluu | 6:51f492ca61a2 | 33 | // returns 0 on success ACK, 1 on NACK |
walterluu | 6:51f492ca61a2 | 34 | // ***************************************************************************** |
walterluu | 6:51f492ca61a2 | 35 | int AO19_write_register(I2C *i2c, char I2C_add, char reg_add, char byte); |
walterluu | 6:51f492ca61a2 | 36 | |
walterluu | 6:51f492ca61a2 | 37 | /// **************************************************************************** |
walterluu | 6:51f492ca61a2 | 38 | // AO19_write_register(char, char, char *, int) writes multiple bytes to AO19 |
walterluu | 6:51f492ca61a2 | 39 | // char I2C address |
walterluu | 6:51f492ca61a2 | 40 | // char AO19 register address |
walterluu | 6:51f492ca61a2 | 41 | // char * data vector of bytes to be written |
walterluu | 6:51f492ca61a2 | 42 | // int number of bytes to write |
walterluu | 6:51f492ca61a2 | 43 | // returns 0 on success ACK, 1 on NACK |
walterluu | 6:51f492ca61a2 | 44 | // ***************************************************************************** |
walterluu | 6:51f492ca61a2 | 45 | int AO19_write_register(I2C *i2c, char I2C_add, char reg_add, char *bytes, int n); |
walterluu | 6:51f492ca61a2 | 46 | |
walterluu | 6:51f492ca61a2 | 47 | // ***************************************************************************** |
walterluu | 6:51f492ca61a2 | 48 | // AO19_read_register(char, char, char *) reads single byte from AO19 |
walterluu | 6:51f492ca61a2 | 49 | // char I2C address |
walterluu | 6:51f492ca61a2 | 50 | // char AO19 register address |
walterluu | 6:51f492ca61a2 | 51 | // char * data vector for read bytes to be stored in |
walterluu | 6:51f492ca61a2 | 52 | // returns 0 on success, 1 on fail |
walterluu | 6:51f492ca61a2 | 53 | // ***************************************************************************** |
walterluu | 6:51f492ca61a2 | 54 | int AO19_read_register(I2C *i2c, char I2C_add, char reg_add, char *bytes); |
walterluu | 6:51f492ca61a2 | 55 | |
walterluu | 6:51f492ca61a2 | 56 | // ***************************************************************************** |
walterluu | 6:51f492ca61a2 | 57 | // AO19_read_register(char, char, char *, int) reads byte(s) from AO19 |
walterluu | 6:51f492ca61a2 | 58 | // char I2C address |
walterluu | 6:51f492ca61a2 | 59 | // char OT07 register address |
walterluu | 6:51f492ca61a2 | 60 | // char * data vector for read bytes to be stored in |
walterluu | 6:51f492ca61a2 | 61 | // int number of bytes to read |
walterluu | 6:51f492ca61a2 | 62 | // returns 0 on success, 1 on fail |
walterluu | 6:51f492ca61a2 | 63 | // ***************************************************************************** |
walterluu | 6:51f492ca61a2 | 64 | int AO19_read_register(I2C *i2c, char I2C_add, char reg_add, char *bytes, int n); |