Exemplo n.º 1
0
/**
 * Test nvm_eeprom_erase_all().
 *
 * Test procedure:
 * - Write one byte to the TEST_ERASE_PAGE page.
 * - Erase all memory locations
 * - Verify that the EEPROM is erased by a spot test on the
 *   TEST_ERASE_PAGE page.
 *
 * \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
 */
static status_code_t test_erase(void)
{
	nvm_eeprom_write_byte(TEST_ERASE_PAGE * EEPROM_PAGE_SIZE, 42);
	nvm_eeprom_erase_all();
	set_buffer(buffer, EEPROM_ERASED);

	if (is_eeprom_page_equal_to_buffer(TEST_ERASE_PAGE, buffer)) {
		return STATUS_OK;
	}

	return ERR_BAD_DATA;
}
Exemplo n.º 2
0
/**
 * \brief Test EEPROM erase
 *
 * This test writes a single byte to test page \ref TEST_ERASE_PAGE, then erases
 * _all_ pages and checks that the test page contains only \ref EEPROM_ERASED.
 *
 * \param test Current test case.
 */
static void run_eeprom_erase_test(const struct test_case *test)
{
	uint8_t buffer[EEPROM_PAGE_SIZE];
	bool    success;

	nvm_eeprom_write_byte(TEST_ERASE_PAGE * EEPROM_PAGE_SIZE, 42);
	nvm_eeprom_erase_all();
	set_buffer(buffer, EEPROM_ERASED);

	success = is_eeprom_page_equal_to_buffer(TEST_ERASE_PAGE, buffer);
	test_assert_true(test, success, "Page was not erased");
}
/**
 * \brief This function will store the calculated calibration value in EEPROM
 *  - Erase all eeprom locations
 *  - Store the calculated calibration value in EEPROM
 */
void rtccalib_store_ppm_val(void)
{
	/* Erase all eeprom locations */
	nvm_eeprom_erase_all();

	/* Store the calculated calibration value in EEPROM at configured
	 * EEPROM address
	 */
	nvm_eeprom_write_byte(RTCCALIB_EEPROM_ADDR_TO_STORE,
			rtccalib_rtc_clk_calib_val);

	/* Store the status of RTC calibration in EEPROM at configured
	 * EEPROM address
	 * Success indicated as 0x01 and failure as 0x02
	 */
	nvm_eeprom_write_byte(RTCCALIB_STAT_EEPROM_ADDR,
			rtccalib_rtc_clk_calib_status);
}
Exemplo n.º 4
0
int main(void)
{
   ADDR_T address = 0;
   unsigned int temp_int=0;
   unsigned char val;
   
   /* Initialization */    
   void (*funcptr)( void ) = 0x0000; // Set up function pointer to RESET vector.
   
   PMIC_SetVectorLocationToBoot();
   
   
   eeprom_disable_mapping();
   
   PROGPORT |= (1<<PROG_NO); // Enable pull-up on PROG_NO line on PROGPORT.
   
   /* Branch to bootloader or application code? */
   if( /*!(PROGPIN & (1<<PROG_NO))*/1 ) // If PROGPIN is pulled low, enter programmingmode.
   {
      initbootuart(); // Initialize UART.

      /* Main loop */
      for(;;)
      {
	 
	 val = recchar(); // Wait for command character.
	 
	 // Check autoincrement status.
	 if(val=='a')
	 {
	    sendchar('Y'); // Yes, we do autoincrement.
	 }
	 
	 // Set address (2 bytes).
	 else if(val == 'A')
	 { // NOTE: Flash addresses are given in words, not bytes.                                            
	    address = recchar();
	    address <<=  8;
	    address |= recchar(); // Read address high and low byte.
	    sendchar('\r'); // Send OK back.
	 }

	 // Set extended address (3 bytes).
	 else if(val == 'H')
	 { // NOTE: Flash addresses are given in words, not bytes.                                            
	    address = (uint32_t)recchar() << 16;
	    address |= (uint16_t)recchar() << 8;
	    address |= recchar();
	    sendchar('\r'); // Send OK back.
	 }

	 // Chip erase.
	 else if(val=='e')
	 {
	    for(address = 0; address < APP_END; address += PAGESIZE)
	    { // NOTE: Here we use address as a byte-address, not word-address, for convenience.
	       nvm_wait_until_ready();
#ifdef __ICCAVR__
#pragma diag_suppress=Pe1053 // Suppress warning for conversion from long-type address to flash ptr.
#endif
	       EraseApplicationPage( address );
#ifdef __ICCAVR__
#pragma diag_default=Pe1053 // Back to default.
#endif
	    }
	    nvm_eeprom_erase_all();
	    sendchar('\r'); // Send OK back.
	 }
	 
#ifndef REMOVE_BLOCK_SUPPORT

	 // Check block load support.
	 else if(val=='b')
	 {
	    sendchar('Y'); // Report block load supported.
	    sendchar((BLOCKSIZE>>8) & 0xFF); // MSB first.
	    sendchar(BLOCKSIZE&0xFF); // Report BLOCKSIZE (bytes).
	 }
	 
	 // Start block load.
	 else if(val=='B')
Exemplo n.º 5
0
bool isp_erase_chip(void)
{
	nvm_flash_erase_app();
	nvm_eeprom_erase_all();
	return true;
}