xref: /btstack/platform/embedded/hal_flash_bank_memory.h (revision 2fca4dad957cd7b88f4657ed51e89c12615dda72)
117ae5bc4SMatthias Ringwald /*
217ae5bc4SMatthias Ringwald  * Copyright (C) 2017 BlueKitchen GmbH
317ae5bc4SMatthias Ringwald  *
417ae5bc4SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
517ae5bc4SMatthias Ringwald  * modification, are permitted provided that the following conditions
617ae5bc4SMatthias Ringwald  * are met:
717ae5bc4SMatthias Ringwald  *
817ae5bc4SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
917ae5bc4SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
1017ae5bc4SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
1117ae5bc4SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
1217ae5bc4SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
1317ae5bc4SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
1417ae5bc4SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
1517ae5bc4SMatthias Ringwald  *    from this software without specific prior written permission.
1617ae5bc4SMatthias Ringwald  *
17*2fca4dadSMilanka Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
1817ae5bc4SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1917ae5bc4SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20*2fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
21*2fca4dadSMilanka Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2217ae5bc4SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2317ae5bc4SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
2417ae5bc4SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2517ae5bc4SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2617ae5bc4SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
2717ae5bc4SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2817ae5bc4SMatthias Ringwald  * SUCH DAMAGE.
2917ae5bc4SMatthias Ringwald  *
3017ae5bc4SMatthias Ringwald  */
3117ae5bc4SMatthias Ringwald 
3217ae5bc4SMatthias Ringwald /*
3317ae5bc4SMatthias Ringwald  *  hal_flash_bank.h
3417ae5bc4SMatthias Ringwald  *
3517ae5bc4SMatthias Ringwald  *  HAL abstraction for Flash memory that can be written anywhere
3617ae5bc4SMatthias Ringwald  *  after being erased implemented with memory
3717ae5bc4SMatthias Ringwald  */
3817ae5bc4SMatthias Ringwald 
3980e33422SMatthias Ringwald #ifndef HAL_FLASH_BANK_MEMORY_H
4080e33422SMatthias Ringwald #define HAL_FLASH_BANK_MEMORY_H
4117ae5bc4SMatthias Ringwald 
4217ae5bc4SMatthias Ringwald #include <stdint.h>
4317ae5bc4SMatthias Ringwald #include "hal_flash_bank.h"
4417ae5bc4SMatthias Ringwald 
4517ae5bc4SMatthias Ringwald #if defined __cplusplus
4617ae5bc4SMatthias Ringwald extern "C" {
4717ae5bc4SMatthias Ringwald #endif
4817ae5bc4SMatthias Ringwald 
4917ae5bc4SMatthias Ringwald // private
5017ae5bc4SMatthias Ringwald typedef struct {
5117ae5bc4SMatthias Ringwald 	uint32_t   bank_size;
5217ae5bc4SMatthias Ringwald 	uint8_t  * banks[2];
5317ae5bc4SMatthias Ringwald } hal_flash_bank_memory_t;
5417ae5bc4SMatthias Ringwald 
5517ae5bc4SMatthias Ringwald // public
5617ae5bc4SMatthias Ringwald 
5717ae5bc4SMatthias Ringwald /**
5817ae5bc4SMatthias Ringwald  * Init instance
5917ae5bc4SMatthias Ringwald  * @param context hal_flash_bank_memory_t
6017ae5bc4SMatthias Ringwald  * @param storage to use
6117ae5bc4SMatthias Ringwald  * @param size of storage
6217ae5bc4SMatthias Ringwald  */
6317ae5bc4SMatthias Ringwald const hal_flash_bank_t * hal_flash_bank_memory_init_instance(hal_flash_bank_memory_t * context, uint8_t * storage, uint32_t storage_size);
6417ae5bc4SMatthias Ringwald 
6517ae5bc4SMatthias Ringwald #if defined __cplusplus
6617ae5bc4SMatthias Ringwald }
6717ae5bc4SMatthias Ringwald #endif
6880e33422SMatthias Ringwald #endif // HAL_FLASH_BANK_MEMORY_H
69