|
ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
|
#include "persistent_config.h"#include <assert.h>#include <inttypes.h>#include <malloc.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <string.h>#include "boards/pico.h"#include "hardware/flash.h"#include "hardware/regs/addressmap.h"#include "hardware/sync.h"#include "system/common.h"
Go to the source code of this file.
Macros | |
| #define | FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES - FLASH_SECTOR_SIZE) |
| #define | CONFIG_MAGIC 0xCAFEBABE |
| #define | BYTES_PER_KIBIBYTE 1024U |
| #define | RAM_TOTAL_KIBIBYTES 264U |
| #define | RAM_BASE_ADDRESS 0x20000000U |
| #define | W55RP20_FLASH_TOTAL_BYTES (2U * BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE) |
Functions | |
| void | print_memory_usage (void) |
| Print RAM usage statistics. | |
| void | print_flash_usage (void) |
| Print flash usage statistics. | |
| static const config_t * | nonsafe_config_read (void) |
| bool | config_read (config_t *cfg) |
| Read configuration from flash. | |
| void | config_wipe (void) |
| Erase persistent configuration sector. | |
| bool | config_is_valid (void) |
| Check if flash configuration magic marker is valid. | |
| void | dump_config (void) |
| Print current configuration to console/log output. | |
| void | config_write (const config_t *cfg) |
| Write configuration to flash. | |
| #define BYTES_PER_KIBIBYTE 1024U |
Definition at line 39 of file persistent_config.c.
| #define CONFIG_MAGIC 0xCAFEBABE |
Definition at line 38 of file persistent_config.c.
| #define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES - FLASH_SECTOR_SIZE) |
Definition at line 36 of file persistent_config.c.
| #define RAM_BASE_ADDRESS 0x20000000U |
Definition at line 41 of file persistent_config.c.
| #define RAM_TOTAL_KIBIBYTES 264U |
Definition at line 40 of file persistent_config.c.
| #define W55RP20_FLASH_TOTAL_BYTES (2U * BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE) |
Definition at line 42 of file persistent_config.c.
| bool config_is_valid | ( | void | ) |
Check if flash configuration magic marker is valid.
Definition at line 123 of file persistent_config.c.
References CONFIG_MAGIC, config_t::magic, and nonsafe_config_read().
Referenced by main().


| bool config_read | ( | config_t * | cfg | ) |
Read configuration from flash.
| cfg | Destination object. |
Definition at line 103 of file persistent_config.c.
References CONFIG_MAGIC, config_t::magic, and nonsafe_config_read().
Referenced by main().


| void config_wipe | ( | void | ) |
Erase persistent configuration sector.
Definition at line 114 of file persistent_config.c.
References FLASH_TARGET_OFFSET.
Referenced by event_dispatch().

| void config_write | ( | const config_t * | cfg | ) |
Write configuration to flash.
| cfg | Source config object. |
Definition at line 177 of file persistent_config.c.
References CONFIG_MAGIC, FLASH_TARGET_OFFSET, and config_t::magic.
Referenced by event_dispatch().

| void dump_config | ( | void | ) |
Print current configuration to console/log output.
Definition at line 129 of file persistent_config.c.
References V24_CONFIG_T::baudrate, NETWORK_CONFIG_T::broadcast_address, CONFIG_MAGIC, V24_TX_POLARITIES_T::cts_inverted, V24_RX_POLARITIES_T::dcd_inverted, V24_TX_POLARITIES_T::dtr_inverted, UDP_CONFIG_T::ip_address, config_t::local_config, LOG_INFO, config_t::magic, config_t::net_config, NETWORK_CONFIG_T::net_info, nonsafe_config_read(), V24_CONFIG_T::polarities, UDP_CONFIG_T::port, PRIu32, PRIX32, config_t::remote_config, V24_TX_POLARITIES_T::rts_inverted, V24_POLARITIES_T::rx_polarities, V24_RX_POLARITIES_T::rxc_inverted, V24_RX_POLARITIES_T::rxd_inverted, V24_POLARITIES_T::tx_polarities, V24_TX_POLARITIES_T::txc_inverted, V24_TX_POLARITIES_T::txd_inverted, config_t::v24_config, and config_t::version.
Referenced by event_dispatch(), and main().


|
static |
Definition at line 98 of file persistent_config.c.
References FLASH_TARGET_OFFSET.
Referenced by config_is_valid(), config_read(), and dump_config().

| void print_flash_usage | ( | void | ) |
Print flash usage statistics.
Definition at line 78 of file persistent_config.c.
References BYTES_PER_KIBIBYTE, LOG_PLAIN, PRIu32, and W55RP20_FLASH_TOTAL_BYTES.
Referenced by event_dispatch().

| void print_memory_usage | ( | void | ) |
Print RAM usage statistics.
Definition at line 44 of file persistent_config.c.
References BYTES_PER_KIBIBYTE, LOG_PLAIN, PRIu32, RAM_BASE_ADDRESS, and RAM_TOTAL_KIBIBYTES.
Referenced by event_dispatch().
