Merge branch 'ds1307_NVRAM'
This commit is contained in:
@@ -42,6 +42,58 @@ static uint8_t ds1307_read_byte(uint8_t ds1307_reg_addres);
|
||||
static uint8_t ds1307_bcd_decode(uint8_t data);
|
||||
static uint8_t ds1307_bcd_encode(uint8_t data);
|
||||
|
||||
/*
|
||||
*
|
||||
Function designed to read embedded RAM data.
|
||||
Address range 0x08 to 0x3F
|
||||
56 bytes of data
|
||||
|
||||
addr: address of data to read 0x08 to 0x3F
|
||||
data: pointer to data
|
||||
len: number of bytes of data to read
|
||||
|
||||
*/
|
||||
|
||||
uint8_t ds1307_read_user_RAM(uint8_t addr, uint8_t * data, uint8_t len){
|
||||
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
for(uint8_t i = 0; i < len; i++){
|
||||
uint8_t resp = ds1307_read_byte(addr + i);
|
||||
*(data + i) = resp;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
Function designed to write embedded RAM data.
|
||||
Address range 0x08 to 0x3F
|
||||
56 bytes of data
|
||||
|
||||
addr: address of data to read 0x08 to 0x3F
|
||||
data: pointer to data
|
||||
len: number of bytes of data to read
|
||||
|
||||
*/
|
||||
|
||||
uint8_t ds1307_write_user_RAM(uint8_t addr, uint8_t * data, uint8_t len){
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
uint8_t buff[4] = {0};
|
||||
buff[0] = addr;
|
||||
|
||||
for(uint8_t i = 0; i < len; i++){
|
||||
|
||||
ds1307_write_byte(addr + i, *(data + i));
|
||||
HAL_Delay(5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write byte data from an specific address ds1307 RTC
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user