xref: /btstack/platform/embedded/btstack_tlv_flash_bank.h (revision 80e33422a96c028b3a9c308fc4b9b874712dafb4)
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  *
1717ae5bc4SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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
2017ae5bc4SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
2117ae5bc4SMatthias Ringwald  * RINGWALD 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  *  btstack_tlv_flash_bank.h
3417ae5bc4SMatthias Ringwald  *
3517ae5bc4SMatthias Ringwald  *  Implementation for BTstack's Tag Value Length Persistent Storage implementations
3617ae5bc4SMatthias Ringwald  *  using hal_flash_bank storage
3717ae5bc4SMatthias Ringwald  */
3817ae5bc4SMatthias Ringwald 
39*80e33422SMatthias Ringwald #ifndef BTSTACK_TLV_FLASH_BANK_H
40*80e33422SMatthias Ringwald #define BTSTACK_TLV_FLASH_BANK_H
4117ae5bc4SMatthias Ringwald 
4217ae5bc4SMatthias Ringwald #include <stdint.h>
4317ae5bc4SMatthias Ringwald #include "btstack_tlv.h"
4417ae5bc4SMatthias Ringwald #include "hal_flash_bank.h"
4517ae5bc4SMatthias Ringwald 
4617ae5bc4SMatthias Ringwald #if defined __cplusplus
4717ae5bc4SMatthias Ringwald extern "C" {
4817ae5bc4SMatthias Ringwald #endif
4917ae5bc4SMatthias Ringwald 
5017ae5bc4SMatthias Ringwald typedef struct {
5117ae5bc4SMatthias Ringwald 	const hal_flash_bank_t * hal_flash_bank_impl;
5217ae5bc4SMatthias Ringwald 	void * hal_flash_bank_context;
5317ae5bc4SMatthias Ringwald 	int current_bank;
5417ae5bc4SMatthias Ringwald 	int write_offset;
5517ae5bc4SMatthias Ringwald } btstack_tlv_flash_bank_t;
5617ae5bc4SMatthias Ringwald 
5717ae5bc4SMatthias Ringwald /**
5817ae5bc4SMatthias Ringwald  * Init Tag Length Value Store
5917ae5bc4SMatthias Ringwald  * @param context btstack_tlv_flash_bank_t
6017ae5bc4SMatthias Ringwald  * @param hal_flash_bank_impl    of hal_flash_bank interface
6117ae5bc4SMatthias Ringwald  * @Param hal_flash_bank_context of hal_flash_bank_interface
6217ae5bc4SMatthias Ringwald  */
6317ae5bc4SMatthias Ringwald const btstack_tlv_t * btstack_tlv_flash_bank_init_instance(btstack_tlv_flash_bank_t * context, const hal_flash_bank_t * hal_flash_bank_impl, void * hal_flash_bank_context);
6417ae5bc4SMatthias Ringwald 
6517ae5bc4SMatthias Ringwald #if defined __cplusplus
6617ae5bc4SMatthias Ringwald }
6717ae5bc4SMatthias Ringwald #endif
68*80e33422SMatthias Ringwald #endif // BTSTACK_TLV_FLASH_BANK_H
69