Callisto4Bootloader: include/c4_qspi.h File Reference

Callisto4Bootloader

Macros | Functions
c4_qspi.h File Reference

Interface to QSPI Flash. More...

`#include "c4_error_codes.h"`
`#include "flexspi_nor_flash.h"`
`#include <stdint.h>`

Go to the source code of this file.

## Macros

#define | max(a, b)
| Maximum. More...
#define | min(a, b)
| Minimum. More...

## Functions

exit_code_t | C4_QSPI_init (void)
| Initialise the flexSPI interface to QSPI. More...
exit_code_t | C4_QSPI_getConfig (flexspi_nor_config_t *pConfig)
| Get the current config of the QSPI flash. More...
exit_code_t | C4_QSPI_erase (uintptr_t addr, size_t len)
| Erase region in QSPI flash memory. More...
exit_code_t | C4_QSPI_read (uintptr_t addr, size_t len, uint8_t *pData)
| Read data from QSPI flash memory. More...
exit_code_t | C4_QSPI_write (uintptr_t addr, size_t len, const uint8_t *pData)
| Write data to QSPI flash memory. More...

## Detailed Description

Interface to QSPI Flash.

Copyright
  2020 Remsdaq Ltd.

Date
  19 Mar 2020

Author
  Dan Smithers dwhs@.nosp@m.rems.nosp@m.daq.c.nosp@m.om

Definition in file c4_qspi.h.

## Macro Definition Documentation

## ◆ max

#define max | ( |  | a,
|  |  | b
| ) |  |

Value:
({ \
__typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; \
})

Maximum.

Parameters

  [in] | a | first value
  [in] | b | second value

Returns
  a if a > b otherwise b

Definition at line 26 of file c4_qspi.h.

## ◆ min

#define min | ( |  | a,
|  |  | b
| ) |  |

Value:
({ \
__typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; \
})

Minimum.

Parameters

  [in] | a | first value
  [in] | b | second value

Returns
  a if a < b otherwise b

Definition at line 41 of file c4_qspi.h.

## Function Documentation

## ◆ C4_QSPI_erase()

exit_code_t C4_QSPI_erase | ( | uintptr_t | addr,
|  | size_t | len
| ) |  |

Erase region in QSPI flash memory.

The memory is erased page by page. Whole pages are erased. Partial pages (at either end of the region are read and then updated before being erased and reprogrammed.

Warning
  Currently none of these QSPI functions are thread safe.

Parameters

  [in] | addr | Start address to erase from.
  [in] | len | Number of bytes to erase.

Returns
  Exit code.

Definition at line 123 of file c4_qspi.c.

References C4_FLASH_INSTANCE, C4_FLASH_SECTOR_SIZE, C4_PRINT, C4_QSPI_write(), FLASH_INITIALISED, FlexSPI_AMBA_BASE, flexspi_nor_flash_erase(), _flexspi_nor_config::memConfig, _FlexSPIConfig::sflashA1Size, and sFlashConfig.

Referenced by QSPI_test().

## ◆ C4_QSPI_getConfig()

exit_code_t C4_QSPI_getConfig | ( | flexspi_nor_config_t * | pConfig | ) |

Get the current config of the QSPI flash.

Parameters

  [out] | pConfig | Pointer to return the configuration.

Returns
  Exit code.

< [0x000-0x003] Tag, fixed value 0x42464346UL

< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix

Definition at line 97 of file c4_qspi.c.

References C4_FLASH_INSTANCE, C4_PRINT, flexspi_nor_get_config(), _flexspi_nor_config::memConfig, sFlashConfigOption, _FlexSPIConfig::tag, and _FlexSPIConfig::version.

Referenced by C4_QSPI_init().

## ◆ C4_QSPI_init()

exit_code_t C4_QSPI_init | ( | void |  | ) |

Initialise the flexSPI interface to QSPI.

Returns
  Exit code

Definition at line 74 of file c4_qspi.c.

References bl_api_init(), C4_FLASH_INSTANCE, C4_QSPI_getConfig(), FLASH_INITIALISED, flexspi_nor_flash_init(), _serial_nor_config_option::option0, sFlashConfig, sFlashConfigOption, and _serial_nor_config_option::U.

Referenced by QSPI_test().

## ◆ C4_QSPI_read()

exit_code_t C4_QSPI_read | ( | uintptr_t | addr,
|  | size_t | len,
|  | uint8_t * | pData
| ) |  |

Read data from QSPI flash memory.

Possibly nugatory as the QSPI can be read as if memory mapped.

Warning
  Currently none of these QSPI functions are thread safe.

Parameters

  [in] | addr | Start address to read from.
  [in] | len | Number of bytes to read.
  [out] | pData | Array to receive data. The caller ensures that this is large enough to receive the specified number of bytes.

Returns
  Exit code.

Read data from Serial NOR

Definition at line 184 of file c4_qspi.c.

References C4_FLASH_INSTANCE, C4_PRINT, FLASH_INITIALISED, FlexSPI_AMBA_BASE, flexspi_nor_flash_read(), _flexspi_nor_config::memConfig, _FlexSPIConfig::sflashA1Size, and sFlashConfig.

Referenced by doReadTest(), and QSPI_test().

## ◆ C4_QSPI_write()

exit_code_t C4_QSPI_write | ( | uintptr_t | addr,
|  | size_t | len,
|  | const uint8_t * | pData
| ) |  |

Write data to QSPI flash memory.

The data are written page by page. Whole pages are erased and programmed. Partial pages (at either end of the region are read and then updated before being erased and reprogrammed.

Warning
  Currently none of these QSPI functions are thread safe.

Parameters

  [in] | addr | Start address to write to.
  [in] | len | Number of bytes to write.
  [in] | pData | Array containing data to be written.

Returns
  Exit code.

Definition at line 230 of file c4_qspi.c.

References C4_FLASH_INSTANCE, C4_FLASH_SECTOR_SIZE, C4_PRINT, FLASH_INITIALISED, FlexSPI_AMBA_BASE, flexspi_nor_flash_read(), _flexspi_nor_config::memConfig, _FlexSPIConfig::sflashA1Size, sFlashConfig, and writeSector().

Referenced by C4_QSPI_erase(), doReadTest(), doWriteTest(), and QSPI_test().