int main(void) { //! [init] /* Init system. */ //! [system_init] system_init(); //! [system_init] /* Configure device and enable. */ //! [temp_init] at30tse_init(); //! [temp_init] //! [init] //! [impl] /* Read thigh and tlow */ //! [read_thigh] volatile uint16_t thigh = 0; thigh = at30tse_read_register(AT30TSE_THIGH_REG, AT30TSE_NON_VOLATILE_REG, AT30TSE_THIGH_REG_SIZE); //! [read_thigh] //! [read_tlow] volatile uint16_t tlow = 0; tlow = at30tse_read_register(AT30TSE_TLOW_REG, AT30TSE_NON_VOLATILE_REG, AT30TSE_TLOW_REG_SIZE); //! [read_tlow] /* Set 12-bit resolution mode. */ //! [write_conf] at30tse_write_config_register( AT30TSE_CONFIG_RES(AT30TSE_CONFIG_RES_12_bit)); //! [write_conf] //! [read_temp] while (1) { temp_res = at30tse_read_temperature(); } //! [read_temp] //! [impl] UNUSED(tlow); UNUSED(thigh); }
int main(void) { volatile double temper_value; volatile bool data_check_status1 = true, data_check_status2 = true; uint32_t i; system_clock_config(CLOCK_RESOURCE_XO_26_MHZ, CLOCK_FREQ_26_MHZ); /* Initialize AT30TS(E)75x */ at30tse_init(); /* First round data check */ for (i = 0; i < NB_BYTE; i++) { tx_buffer[i] = i; } /* Write pages in EEPROM */ for (i = 0; i < NB_PAGE; i++) { at30tse_eeprom_write(tx_buffer, NB_BYTE, 0, i); delay(200); } /* Read each page in EEPROM and compare them */ for (i = 0; i < NB_PAGE; i++) { memset(rx_buffer, 0, NB_BYTE); at30tse_eeprom_read(rx_buffer, NB_BYTE, 0, i); if (memcmp(tx_buffer, rx_buffer, NB_BYTE)) { data_check_status1 = false; break; } } /* Second round data check */ for (i = 0; i < NB_BYTE; i++) { tx_buffer[i] = NB_BYTE - i; } /* Write pages in EEPROM */ for (i = 0; i < NB_PAGE; i++) { at30tse_eeprom_write(tx_buffer, NB_BYTE, 0, i); delay(200); } /* Read each page in EEPROM and compare them */ for (i = 0; i < NB_PAGE; i++) { memset(rx_buffer, 0, NB_BYTE); at30tse_eeprom_read(rx_buffer, NB_BYTE, 0, i); if (memcmp(tx_buffer, rx_buffer, NB_BYTE)) { data_check_status2 = false; break; } } /* Read thigh and tlow */ volatile uint16_t thigh = 0; thigh = at30tse_read_register(AT30TSE_THIGH_REG, AT30TSE_NON_VOLATILE_REG, AT30TSE_THIGH_REG_SIZE); volatile uint16_t tlow = 0; tlow = at30tse_read_register(AT30TSE_TLOW_REG, AT30TSE_NON_VOLATILE_REG, AT30TSE_TLOW_REG_SIZE); /* Set 12-bit resolution mode. */ at30tse_write_config_register( AT30TSE_CONFIG_RES(AT30TSE_CONFIG_RES_12_bit)); while (1) { /* Read current temperature. */ temper_value = at30tse_read_temperature(); } UNUSED(data_check_status1); UNUSED(data_check_status2); UNUSED(temper_value); UNUSED(tlow); UNUSED(thigh); }