px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_flash.h
1#ifndef __PX_FLASH_H__
2#define __PX_FLASH_H__
3/* =============================================================================
4 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
5 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
6 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
7 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
8 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
9
10 Copyright (c) 2006 Pieter Conradie <https://piconomix.com>
11
12 License: MIT
13 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
14
15 Title: px_flash.h : Internal FLASH write routines
16 Author(s): Pieter Conradie
17 Creation Date: 2007-03-31
18
19============================================================================= */
20
21/**
22 * @ingroup AVR
23 * @defgroup AVR_FLASH px_flash.h : Internal FLASH write routines
24 *
25 * This component can clear and write a page of internal FLASH.
26 *
27 * File(s):
28 * - arch/avr/inc/px_flash.h
29 * - arch/avr/src/px_flash.c
30 *
31 * @warn_s
32 * These routines must always reside in the bootloader section. If mixing
33 * application code and bootloader code, the prefix BOOTLOADER_SECTION can be
34 * used to place these functions in a section called ".bootloader".
35 * See <avr/boot.h>
36 * @warn_e
37 *
38 * Example of setting ".bootloader" section address in Makefile:
39 *
40 * LDFLAGS += -Wl,--section-start,.bootloader=0x1FF00
41 *
42 * @{
43 */
44
45/* _____STANDARD INCLUDES____________________________________________________ */
46#include <avr/io.h>
47
48/* _____PROJECT INCLUDES_____________________________________________________ */
49#include "px_defs.h"
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54/* _____DEFINITIONS__________________________________________________________ */
55/// FLASH Page size in bytes
56#define PX_FLASH_PAGE_SIZE SPM_PAGESIZE
57
58/// Total number of FLASH pages (application and bootloader section)
59#define PX_FLASH_NR_OF_PAGES ((PX_FLASHEND + 1) / PX_FLASH_PAGE_SIZE)
60
61/* _____GLOBAL FUNCTION DECLARATIONS_________________________________________ */
62/**
63 * Function to erase a page.
64 *
65 * @param page 0 to (#PX_FLASH_NR_OF_PAGES - 1)
66 */
67void px_flash_erase_page(const uint16_t page);
68
69/**
70 * Function to write a page.
71 *
72 * @param page 0 to (#PX_FLASH_NR_OF_PAGES - 1)
73 * @param data Pointer to buffer containing data to write
74 */
75void px_flash_wr_page(const uint16_t page, const uint8_t * data);
76
77/* _____MACROS_______________________________________________________________ */
78
79#ifdef __cplusplus
80}
81#endif
82
83/// @}
84#endif
void px_flash_wr_page(const uint16_t page, const uint8_t *data)
Function to write a page.
Definition: px_flash.c:60
void px_flash_erase_page(uint32_t adr)
Function to erase a page.