1*065fc9a3SMatthias Ringwald /* 2*065fc9a3SMatthias Ringwald * Copyright (C) 2022 BlueKitchen GmbH 3*065fc9a3SMatthias Ringwald * 4*065fc9a3SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5*065fc9a3SMatthias Ringwald * modification, are permitted provided that the following conditions 6*065fc9a3SMatthias Ringwald * are met: 7*065fc9a3SMatthias Ringwald * 8*065fc9a3SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9*065fc9a3SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10*065fc9a3SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11*065fc9a3SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12*065fc9a3SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13*065fc9a3SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14*065fc9a3SMatthias Ringwald * contributors may be used to endorse or promote products derived 15*065fc9a3SMatthias Ringwald * from this software without specific prior written permission. 16*065fc9a3SMatthias Ringwald * 17*065fc9a3SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 18*065fc9a3SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19*065fc9a3SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20*065fc9a3SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 21*065fc9a3SMatthias Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22*065fc9a3SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23*065fc9a3SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 24*065fc9a3SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25*065fc9a3SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26*065fc9a3SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 27*065fc9a3SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28*065fc9a3SMatthias Ringwald * SUCH DAMAGE. 29*065fc9a3SMatthias Ringwald * 30*065fc9a3SMatthias Ringwald */ 31*065fc9a3SMatthias Ringwald 32*065fc9a3SMatthias Ringwald /* 33*065fc9a3SMatthias Ringwald * hal_flash_bank_chibios.h 34*065fc9a3SMatthias Ringwald * 35*065fc9a3SMatthias Ringwald * HAL abstraction for Flash memory that can be written anywhere 36*065fc9a3SMatthias Ringwald * after being erased 37*065fc9a3SMatthias Ringwald */ 38*065fc9a3SMatthias Ringwald 39*065fc9a3SMatthias Ringwald #ifndef HAL_FLASH_BANK_CHIBIOS_H 40*065fc9a3SMatthias Ringwald #define HAL_FLASH_BANK_CHIBIOS_H 41*065fc9a3SMatthias Ringwald 42*065fc9a3SMatthias Ringwald #include <stdint.h> 43*065fc9a3SMatthias Ringwald #include "hal_flash_bank.h" 44*065fc9a3SMatthias Ringwald 45*065fc9a3SMatthias Ringwald #if defined __cplusplus 46*065fc9a3SMatthias Ringwald extern "C" { 47*065fc9a3SMatthias Ringwald #endif 48*065fc9a3SMatthias Ringwald 49*065fc9a3SMatthias Ringwald typedef struct { 50*065fc9a3SMatthias Ringwald uint32_t sector_size; 51*065fc9a3SMatthias Ringwald uint16_t sectors[2]; 52*065fc9a3SMatthias Ringwald uintptr_t banks[2]; 53*065fc9a3SMatthias Ringwald } hal_flash_bank_chbios_t; 54*065fc9a3SMatthias Ringwald 55*065fc9a3SMatthias Ringwald /** 56*065fc9a3SMatthias Ringwald * Configure HAL Flash Implementation 57*065fc9a3SMatthias Ringwald * 58*065fc9a3SMatthias Ringwald * @param context of hal_flash_bank_chbios_t 59*065fc9a3SMatthias Ringwald * @param bank_0_sector 60*065fc9a3SMatthias Ringwald * @param bank_1_sector 61*065fc9a3SMatthias Ringwald * @return 62*065fc9a3SMatthias Ringwald */ 63*065fc9a3SMatthias Ringwald const hal_flash_bank_t * hal_flash_bank_chibios_init_instance(hal_flash_bank_chbios_t * context, 64*065fc9a3SMatthias Ringwald uint16_t bank_0_sector, uint16_t bank_1_sector); 65*065fc9a3SMatthias Ringwald 66*065fc9a3SMatthias Ringwald #if defined __cplusplus 67*065fc9a3SMatthias Ringwald } 68*065fc9a3SMatthias Ringwald #endif 69*065fc9a3SMatthias Ringwald #endif 70