#include <string.h>
#include "compiler.h"
#include "preprocessor.h"
#include "board.h"
#include "print_funcs.h"
#include "power_clocks_lib.h"
#include "gpio.h"
#include "usart.h"
#include "spi.h"
#include "conf_at45dbx.h"
#include "fsaccess.h"
Macros | |
#define | ABORT_CHAR CTRL_C |
#define | AT45DBX_ENABLE_NPCS_PIN(NPCS, unused) {AT45DBX_SPI_NPCS##NPCS##_PIN, AT45DBX_SPI_NPCS##NPCS##_FUNCTION}, |
#define | BKSPACE_CHAR '\b' |
#define | CR '\r' |
#define | CRLF "\r\n" |
#define | CTRL_C 0x03 |
#define | CTRL_Q 0x11 |
#define | LF '\n' |
#define | MSG_FILENAME "Enter the filename : " |
#define | MSG_MODE "\r\nWhat do you want to do ?\r\n\t1 - Read file\r\n\t2 - Concatenate a file to an existing one\r\n\t3 - Copy the content of a file to a new one\r\nenter your choice : " |
#define | MSG_WELCOME "\r\n ---------- Welcome to FSACCESS Example ---------- \r\n" |
#define | NB_SECTOR_TO_SEND 4 |
#define | QUIT_APPEND CTRL_Q |
#define | TEST_FAIL "\t[FAIL]\r\n" |
#define | TEST_SUCCESS "\t[PASS]\r\n" |
Functions | |
static void | at45dbx_resources_init (void) |
Initialize dataflash memory AT45DBX resources: GPIO, SPI and AT45DBX. More... | |
void | fsaccess_example_get_filename (char *buf) |
Wait for user to enter a filename. More... | |
int | fsaccess_example_get_mode (void) |
Wait for user to select the mode he wants to test. More... | |
int | fsaccess_example_read (char *path) |
Read a file and display it to USART. More... | |
int | fsaccess_example_write (char *source, char *destination, int flags) |
Copy a file to another one. More... | |
int | main (void) |
Main function, execution starts here. RS232 is used to input/output information. The example lets you issue the following commands on RS232 using POSIX interfaces (open, read, write, close): More... | |
Parameters to pcl_configure_clocks(). | |
#define | EXAMPLE_TARGET_PBACLK_FREQ_HZ FOSC0 |
#define | EXAMPLE_TARGET_DFLL_FREQ_HZ 96000000 |
#define | EXAMPLE_TARGET_MCUCLK_FREQ_HZ 12000000 |
#define | EXAMPLE_TARGET_PBACLK_FREQ_HZ 12000000 |
static scif_gclk_opt_t | gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false } |
static pcl_freq_param_t | pcl_dfll_freq_param |
#define ABORT_CHAR CTRL_C |
Referenced by fsaccess_example_get_filename().
#define AT45DBX_ENABLE_NPCS_PIN | ( | NPCS, | |
unused | |||
) | {AT45DBX_SPI_NPCS##NPCS##_PIN, AT45DBX_SPI_NPCS##NPCS##_FUNCTION}, |
Referenced by at45dbx_resources_init().
#define BKSPACE_CHAR '\b' |
Referenced by fsaccess_example_get_filename().
#define CR '\r' |
Referenced by fsaccess_example_get_filename().
#define CRLF "\r\n" |
Referenced by fsaccess_example_get_filename(), fsaccess_example_get_mode(), and fsaccess_example_read().
#define CTRL_C 0x03 |
#define CTRL_Q 0x11 |
#define EXAMPLE_TARGET_DFLL_FREQ_HZ 96000000 |
#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ 12000000 |
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ FOSC0 |
Referenced by at45dbx_resources_init(), and main().
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ 12000000 |
#define LF '\n' |
#define MSG_FILENAME "Enter the filename : " |
Referenced by fsaccess_example_get_filename().
#define MSG_MODE "\r\nWhat do you want to do ?\r\n\t1 - Read file\r\n\t2 - Concatenate a file to an existing one\r\n\t3 - Copy the content of a file to a new one\r\nenter your choice : " |
Referenced by fsaccess_example_get_mode().
#define MSG_WELCOME "\r\n ---------- Welcome to FSACCESS Example ---------- \r\n" |
Referenced by main().
#define NB_SECTOR_TO_SEND 4 |
Referenced by fsaccess_example_read(), and fsaccess_example_write().
#define QUIT_APPEND CTRL_Q |
#define TEST_FAIL "\t[FAIL]\r\n" |
#define TEST_SUCCESS "\t[PASS]\r\n" |
|
static |
Initialize dataflash memory AT45DBX resources: GPIO, SPI and AT45DBX.
References AT45DBX_ENABLE_NPCS_PIN, at45dbx_init(), AT45DBX_MEM_CNT, AT45DBX_SPI, AT45DBX_SPI_BITS, AT45DBX_SPI_FIRST_NPCS, AT45DBX_SPI_MASTER_SPEED, AT45DBX_SPI_MISO_FUNCTION, AT45DBX_SPI_MISO_PIN, AT45DBX_SPI_MOSI_FUNCTION, AT45DBX_SPI_MOSI_PIN, AT45DBX_SPI_SCK_FUNCTION, AT45DBX_SPI_SCK_PIN, EXAMPLE_TARGET_PBACLK_FREQ_HZ, gpio_enable_module(), MREPEAT, spi_options_t::reg, spi_enable(), spi_initMaster(), and spi_selectionMode().
Referenced by main().
void fsaccess_example_get_filename | ( | char * | buf | ) |
Wait for user to enter a filename.
References ABORT_CHAR, BKSPACE_CHAR, CR, CRLF, DBG_USART, MSG_FILENAME, print_dbg(), print_dbg_char(), usart_read_char(), usart_reset_status(), and USART_SUCCESS.
Referenced by main().
int fsaccess_example_get_mode | ( | void | ) |
Wait for user to select the mode he wants to test.
References CRLF, DBG_USART, MSG_MODE, print_dbg(), print_dbg_char(), usart_read_char(), usart_reset_status(), and USART_SUCCESS.
Referenced by main().
int fsaccess_example_read | ( | char * | path | ) |
Read a file and display it to USART.
References close(), CRLF, FS_SIZE_OF_SECTOR, fsaccess_file_get_size(), NB_SECTOR_TO_SEND, O_RDONLY, open(), print_dbg(), print_dbg_ulong(), and read().
Referenced by main().
int fsaccess_example_write | ( | char * | source, |
char * | destination, | ||
int | flags | ||
) |
Copy a file to another one.
References close(), FS_SIZE_OF_SECTOR, fsaccess_file_get_size(), NB_SECTOR_TO_SEND, O_RDONLY, open(), print_dbg(), print_dbg_ulong(), read(), and write().
Referenced by main().
int main | ( | void | ) |
Main function, execution starts here. RS232 is used to input/output information. The example lets you issue the following commands on RS232 using POSIX interfaces (open, read, write, close):
Connect USART_1 to your serial port via a standard RS-232 D-SUB9 cable Set the following settings in your terminal of choice: 57600 8N1
References at45dbx_mem_check(), at45dbx_resources_init(), b_fsaccess_init(), EXAMPLE_TARGET_PBACLK_FREQ_HZ, FOSC0, fsaccess_example_get_filename(), fsaccess_example_get_mode(), fsaccess_example_read(), fsaccess_example_write(), init_dbg_rs232(), MSG_WELCOME, O_APPEND, O_CREAT, OSC0_STARTUP, pcl_configure_clocks(), pcl_dfll_freq_param, PCL_OSC0, pcl_switch_to_osc(), and print_dbg().
|
static |
|
static |
Referenced by main().