Exemplo n.º 1
0
Bool at45dbx_mem_check(void)
{
  U8 df;
  U16 status = 0;

  // DF memory check.
  for (df = 0; df < AT45DBX_MEM_CNT; df++)
  {
    // Select the DF memory to check.
    at45dbx_chipselect_df(df, TRUE);

    // Send the Status Register Read command.
    spi_write(AT45DBX_SPI, AT45DBX_CMDC_RD_STATUS_REG);

    // Send a dummy byte to read the status register.
    spi_write_dummy();
    spi_read(AT45DBX_SPI, &status);

    // Unselect the checked DF memory.
    at45dbx_chipselect_df(df, FALSE);

    // Unexpected device density value.
    if ((status & AT45DBX_MSK_DENSITY) < AT45DBX_DENSITY) return KO;
  }

  return OK;
}
Exemplo n.º 2
0
bool at45dbx_mem_check(void)
{
	uint8_t df;
	uint8_t status = 0;

	// DF memory check.
	for (df = 0; df < AT45DBX_MEM_CNT; df++) {
		// Select the DF memory to check.
		at45dbx_chipselect_df(df, true);
		// Send the Status Register Read command.
		at45dbx_spi_write_byte(AT45DBX_CMDC_RD_STATUS_REG);
		// Send a dummy byte to read the status register.
			at45dbx_spi_read_byte(&status);
		// Unselect the checked DF memory.
		at45dbx_chipselect_df(df, false);
		// Unexpected device density value.
		if ((status & AT45DBX_MSK_DENSITY) < AT45DBX_DENSITY) {
			return false;
		}
	}
	return true;
}