#include <string.h>
#include "compiler.h"
#include "preprocessor.h"
#include "board.h"
#include "power_clocks_lib.h"
#include "gpio.h"
#include "spi.h"
#include "conf_at45dbx.h"
#include "at45dbx.h"
#include "clocks.h"
Go to the source code of this file.
Defines | |
#define | AT45DBX_ENABLE_NPCS_PIN(NPCS, unused) { AT45DBX_SPI_NPCS##NPCS##_PIN, AT45DBX_SPI_NPCS##NPCS##_FUNCTION }, |
Functions | |
void | flash_init (void) |
void | flash_read (U32 addr, U8 *buf, U32 len) |
void | flash_write (U32 addr, const U8 *buf, U32 len) |
#define AT45DBX_ENABLE_NPCS_PIN | ( | NPCS, | |||
unused | ) | { AT45DBX_SPI_NPCS##NPCS##_PIN, AT45DBX_SPI_NPCS##NPCS##_FUNCTION }, |
Referenced by flash_init().
void flash_init | ( | void | ) |
Definition at line 40 of file nor_flash.c.
References AT45DBX_ENABLE_NPCS_PIN, and FPBA_HZ.
Referenced by fw_download_init().
00041 { 00042 static const gpio_map_t AT45DBX_SPI_GPIO_MAP = { 00043 { AT45DBX_SPI_SCK_PIN, AT45DBX_SPI_SCK_FUNCTION }, 00044 { AT45DBX_SPI_MISO_PIN, AT45DBX_SPI_MISO_FUNCTION }, 00045 { AT45DBX_SPI_MOSI_PIN, AT45DBX_SPI_MOSI_FUNCTION }, 00046 #define AT45DBX_ENABLE_NPCS_PIN(NPCS, unused) \ 00047 { AT45DBX_SPI_NPCS##NPCS##_PIN, AT45DBX_SPI_NPCS##NPCS##_FUNCTION }, 00048 MREPEAT(AT45DBX_MEM_CNT, AT45DBX_ENABLE_NPCS_PIN, ~) 00049 #undef AT45DBX_ENABLE_NPCS_PIN 00050 }; 00051 00052 spi_options_t spiOptions = { 00053 .reg = AT45DBX_SPI_FIRST_NPCS, 00054 .baudrate = AT45DBX_SPI_MASTER_SPEED, 00055 .bits = AT45DBX_SPI_BITS, 00056 .spck_delay = 0, 00057 .trans_delay = 0, 00058 .stay_act = 1, 00059 .spi_mode = 0, 00060 .modfdis = 1 00061 }; 00062 00063 gpio_enable_module(AT45DBX_SPI_GPIO_MAP, 00064 sizeof(AT45DBX_SPI_GPIO_MAP) / 00065 sizeof(AT45DBX_SPI_GPIO_MAP[0])); 00066 00067 spi_initMaster(AT45DBX_SPI, &spiOptions); 00068 00069 spi_selectionMode(AT45DBX_SPI, 0, 0, 0); 00070 spi_enable(AT45DBX_SPI); 00071 at45dbx_init(spiOptions, FPBA_HZ); 00072 }
void flash_read | ( | U32 | addr, | |
U8 * | buf, | |||
U32 | len | |||
) |
Definition at line 86 of file nor_flash.c.
Referenced by fw_download_cb().
00087 { 00088 U32 sector = addr / AT45DBX_SECTOR_SIZE; 00089 U32 i; 00090 Assert(addr % AT45DBX_SECTOR_SIZE == 0); 00091 00092 at45dbx_read_open(sector); 00093 for (i = 0; i < len; i++) 00094 buf[i] = at45dbx_read_byte(); 00095 at45dbx_read_close(); 00096 }
void flash_write | ( | U32 | addr, | |
const U8 * | buf, | |||
U32 | len | |||
) |
Definition at line 74 of file nor_flash.c.
00075 { 00076 U32 sector = addr / AT45DBX_SECTOR_SIZE; 00077 U32 i; 00078 Assert(addr % AT45DBX_SECTOR_SIZE == 0); 00079 00080 at45dbx_write_open(sector); 00081 for (i = 0; i < len; i++) 00082 at45dbx_write_byte(buf[i]); 00083 at45dbx_write_close(); 00084 }