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.
Dependencies: SX1276GenericLib USBDevice
Fork of NonPingPong_PICO_LoRa by
OT07_lib.h
00001 #include "mbed.h" 00002 00003 //OT07 Registers 00004 #define OT07_STATUS 0x00 // OT07 status regiter 00005 #define OT07_INT_EN 0x01 // OT07 Interrupt Enable 00006 #define OT07_FIFO_W 0x04 // OT07 FIFO Write Pointer 00007 #define OT07_FIFO_R 0x05 // OT07 FIFO Read Pointer 00008 #define OT07_FIFO_OF 0x06 // OT07 FIFO Overflow Counter 00009 #define OT07_FIFO_COUNT 0x07 // OT07 FIFO Data Count 00010 #define OT07_FIFO_DATA 0x08 // OT07 FIFO Data 00011 #define OT07_FIFO_CNFG1 0x09 // OT07 FIFO Configuration 1 (FIFO_A_FULL) 00012 #define OT07_FIFO_CNFG2 0x0A // OT07 FIFO Configuration 2 00013 #define OT07_SYS 0x0C // OT07 System Configuration 00014 #define OT07_ALARM_HIGH_MSB 0x10 // OT07 Alarm High MSB 00015 #define OT07_ALARM_HIGH_LSB 0x11 // OT07 Alarm High LSB 00016 #define OT07_ALARM_LOW_MSB 0x12 // OT07 Alarm Low MSB 00017 #define OT07_ALARM_LOW_LSB 0x13 // OT07 Alarm LOW LSB 00018 #define OT07_ADC_SETUP 0x14 // OT07 Temp Seneor Setup (ADC_RES[7:6]) & Convert Temperature [0] 00019 #define OT07_GPIO_SETUP 0x20 // OT07 GPIO Setup, sets GPIO modes 00020 #define OT07_GPIO_CTRL 0x21 // OT07 GPIO control 00021 #define OT07_ROM_ID 0x31 // OT07 ROM_ID address of LSB? 00022 00023 #define DEVICE_ACK 0 00024 #define DEVICE_NACK 1 00025 #define DEVICE_BAD_RESP 2 00026 00027 #define MAX_DEVICES 64 // Maximum number of rom devices allowed 00028 #define ID_LENGTH 6 // Rom ID length in bytes 00029 00030 struct OT07_struct { 00031 char rom_id[ID_LENGTH]; // device ROM ID 00032 char I2C_address; // I2C addess, based on GPIO0 and GPIO1 at power up 00033 // Why char? 00034 }; 00035 00036 struct TempResponse { 00037 double tempC; // Temperature in °C 00038 int status; // Status of Temperature read. 0 for success, 1 for error 00039 }; 00040 00041 // ***************************************************************************** 00042 // OT07_write_register(char, char, char) writes single byte to OT07 00043 // char I2C address 00044 // char OT07 register address 00045 // char data byte to be writen 00046 // returns 0 on success ACK, 1 on NACK 00047 // ***************************************************************************** 00048 int OT07_write_register(I2C *i2c, char I2C_add, char reg_add, char byte); 00049 00050 /// **************************************************************************** 00051 // OT07_write_register(char, char, char *, int) writes multiple bytes to OT07 00052 // char I2C address 00053 // char OT07 register address 00054 // char * data vector of bytes to be written 00055 // int number of bytes to write 00056 // returns 0 on success ACK, 1 on NACK 00057 // ***************************************************************************** 00058 int OT07_write_register(I2C *i2c, char I2C_add, char reg_add, char *bytes, int n); 00059 00060 // ***************************************************************************** 00061 // OT07_read_register(char, char, char *, int) writes single byte to OT07 00062 // char I2C address 00063 // char OT07 register address 00064 // char * data vector for read bytes to be stored in 00065 // int number of bytes to read 00066 // returns 0 on success, 1 on fail 00067 // ***************************************************************************** 00068 int OT07_read_register(I2C *i2c, char I2C_add, char reg_add, char *bytes, int n); 00069 00070 // ***************************************************************************** 00071 // convert_temperature(char) sends convert command to OT07 device 00072 // char I2C address 00073 // ***************************************************************************** 00074 void convert_temperature(I2C *i2c, char I2C_add); 00075 00076 //****************************************************************************** 00077 // get_temperature(char) read temperature from OT07 device FIFO register 00078 // char I2C address 00079 // returns TempResponse tempC = temperature in oC 00080 // status = register read result 00081 //****************************************************************************** 00082 TempResponse get_temperature(I2C *i2c, char I2C_add); 00083 00084 double calc_temperature(char *data);
Generated on Mon Jul 18 2022 15:25:00 by
1.7.2
