Microchip® Advanced Software Framework

at25dfx_hal_spi.h File Reference

Connection of the AT25DFx SerialFlash to SPI interface driver.

This file manages the connection of the AT25DFx SerialFlash driver to an SPI service (could be spi master service or usart in spi mode). The SPI service selection depends on AT25DFX_USES_SPI_MASTER_SERVICE or AT25DFX_USES_USART_SPI_SERVICE in conf_at25dfx.h.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "conf_at25dfx.h"
#include "status_codes.h"

Macros

#define AT25DFX_CS   0
 
#define AT25DFX_SPI_MODULE   0
 

Functions

void at25dfx_spi_deselect_device (uint8_t mem_id)
 Deselect one external SerialFlash component. More...
 
void at25dfx_spi_init (void)
 Initialize SPI external resource for AT25DFx SerialFlash driver. More...
 
status_code_t at25dfx_spi_read_byte (uint8_t *data)
 Get one byte (read) from the SerialFlash. More...
 
status_code_t at25dfx_spi_read_packet (void const *data, size_t len)
 Receive a sequence of bytes from a SerialFlash. More...
 
void at25dfx_spi_select_device (uint8_t mem_id)
 Select one external SerialFlash component. More...
 
status_code_t at25dfx_spi_write_byte (uint8_t data)
 Send one byte to the SerialFlash. More...
 
status_code_t at25dfx_spi_write_packet (void const *data, size_t len)
 Send a sequence of bytes to a SerialFlash. More...
 

#define AT25DFX_CS   0

void at25dfx_spi_deselect_device ( uint8_t  mem_id)

Deselect one external SerialFlash component.

Parameters
mem_idThe SerialFlash index number.

References AT25DFX_SPI_MODULE, spi_deselect_device(), UNUSED, and usart_spi_deselect_device().

Referenced by at25dfx_send_command().

void at25dfx_spi_init ( void  )

Initialize SPI external resource for AT25DFx SerialFlash driver.

This function initializes the SerialFlash component as well as the SPI service that the memory is connected to.

Precondition
The conf_at25dfx.h file should provide the following information:
  • Selection of the SPI service the SerialFlash is connected (AT25DFX_USES_SPI_MASTER_SERVICE or AT25DFX_USES_USART_SPI_SERVICE).
  • AT25DFX_MEM_SIZE: The SerialFlash type that the driver is connected to.
  • AT25DFX_MEM_CNT: The number of SerialFlash components (number of chipselect).
  • AT25DFX_SPI_MODULE: The name of the SPI module used by the SerialFlash driver.
  • AT25DFX_SPI_MASTER_SPEED: The SPI bus speed.

References AT25DFX_SPI_MODULE, spi_enable(), spi_master_init(), spi_master_setup_device(), SPI_MODE_0, usart_spi_init(), and usart_spi_setup_device().

Referenced by at25dfx_initialize().

status_code_t at25dfx_spi_read_byte ( uint8_t *  data)

Get one byte (read) from the SerialFlash.

Parameters
dataData buffer to read.
Returns
The received byte.
Precondition
The SerialFlash should be selected first using at25dfx_spi_select_device.

References AT25DFX_SPI_MODULE, spi_read_packet(), and usart_spi_read_packet().

status_code_t at25dfx_spi_read_packet ( void const *  data,
size_t  len 
)

Receive a sequence of bytes from a SerialFlash.

Parameters
dataData buffer to read
lenLength of data
Precondition
The SerialFlash should be selected first using at25dfx_spi_select_device

References AT25DFX_SPI_MODULE, spi_read_packet(), and usart_spi_read_packet().

Referenced by at25dfx_send_command().

void at25dfx_spi_select_device ( uint8_t  mem_id)

Select one external SerialFlash component.

Parameters
mem_idThe SerialFlash index number.

References AT25DFX_SPI_MODULE, spi_select_device(), UNUSED, and usart_spi_select_device().

Referenced by at25dfx_send_command().

status_code_t at25dfx_spi_write_byte ( uint8_t  data)

Send one byte to the SerialFlash.

Parameters
dataThe data byte to send.
Precondition
The SerialFlash should be selected first using at25dfx_spi_select_device.

References AT25DFX_SPI_MODULE, spi_write_packet(), and usart_spi_write_packet().

status_code_t at25dfx_spi_write_packet ( void const *  data,
size_t  len 
)

Send a sequence of bytes to a SerialFlash.

Parameters
dataData buffer to write
lenLength of data
Precondition
The SerialFlash should be selected first using at25dfx_spi_select_device

References AT25DFX_SPI_MODULE, spi_write_packet(), and usart_spi_write_packet().

Referenced by at25dfx_send_command().