diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/components/mx25r_flash/mx25r_flash.h')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/components/mx25r_flash/mx25r_flash.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/mx25r_flash/mx25r_flash.h b/lib/chibios-contrib/ext/mcux-sdk/components/mx25r_flash/mx25r_flash.h new file mode 100644 index 000000000..92b87a238 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/components/mx25r_flash/mx25r_flash.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016, Freescale Semiconductor, Inc. | ||
3 | * Copyright 2016-2017 NXP | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * SPDX-License-Identifier: BSD-3-Clause | ||
7 | */ | ||
8 | |||
9 | #ifndef _MX25R_FLASH_H_ | ||
10 | #define _MX25R_FLASH_H_ | ||
11 | |||
12 | #include <stdbool.h> | ||
13 | #include <stdint.h> | ||
14 | #include <stdio.h> | ||
15 | |||
16 | typedef enum mx25r_err | ||
17 | { | ||
18 | mx25r_err_ok = 0, | ||
19 | mx25r_err_out_of_range, | ||
20 | mx25r_err_alignement, | ||
21 | } mx25r_err_t; | ||
22 | |||
23 | typedef int (*transfer_cb_t)(void *transfer_prv, uint8_t *tx_data, uint8_t *rx_data, size_t dataSize, bool eof); | ||
24 | |||
25 | struct mx25r_instance | ||
26 | { | ||
27 | void *prv; | ||
28 | transfer_cb_t callback; | ||
29 | uint8_t cmd[5]; | ||
30 | }; | ||
31 | |||
32 | #if defined(__GNUC__) | ||
33 | #else | ||
34 | __packed | ||
35 | #endif | ||
36 | struct mx25r_rdid_result | ||
37 | { | ||
38 | char manufacturer; | ||
39 | char device[2]; | ||
40 | #if defined(__GNUC__) | ||
41 | } __attribute__((packed)); | ||
42 | #else | ||
43 | }; | ||
44 | #endif | ||
45 | |||
46 | #if defined(__GNUC__) | ||
47 | #else | ||
48 | __packed | ||
49 | #endif | ||
50 | struct mx25r_rdsr_result | ||
51 | { | ||
52 | char sr0; | ||
53 | char sr1; | ||
54 | #if defined(__GNUC__) | ||
55 | } __attribute__((packed)); | ||
56 | #else | ||
57 | }; | ||
58 | #endif | ||
59 | |||
60 | #if defined(__GNUC__) | ||
61 | #else | ||
62 | __packed | ||
63 | #endif | ||
64 | struct mx25r_read_result | ||
65 | { | ||
66 | uint32_t word[4]; | ||
67 | #if defined(__GNUC__) | ||
68 | } __attribute__((packed)); | ||
69 | #else | ||
70 | }; | ||
71 | #endif | ||
72 | |||
73 | union mx25r_result | ||
74 | { | ||
75 | struct mx25r_rdid_result rdid; | ||
76 | struct mx25r_rdsr_result rdsr; | ||
77 | struct mx25r_read_result read; | ||
78 | }; | ||
79 | |||
80 | mx25r_err_t mx25r_init(struct mx25r_instance *instance, transfer_cb_t callback, void *callback_prv); | ||
81 | mx25r_err_t mx25r_cmd_rdid(struct mx25r_instance *instance, struct mx25r_rdid_result *result); | ||
82 | mx25r_err_t mx25r_cmd_read(struct mx25r_instance *instance, uint32_t address, uint8_t *buffer, uint32_t size); | ||
83 | mx25r_err_t mx25r_cmd_nop(struct mx25r_instance *instance); | ||
84 | mx25r_err_t mx25r_cmd_rdsr(struct mx25r_instance *instance, struct mx25r_rdsr_result *result); | ||
85 | mx25r_err_t mx25r_cmd_wrdi(struct mx25r_instance *instance); | ||
86 | mx25r_err_t mx25r_cmd_wren(struct mx25r_instance *instance); | ||
87 | mx25r_err_t mx25r_cmd_write(struct mx25r_instance *instance, | ||
88 | uint32_t address_256_align, | ||
89 | uint8_t *buffer, | ||
90 | uint32_t size_256_max); | ||
91 | mx25r_err_t mx25r_cmd_sector_erase(struct mx25r_instance *instance, uint32_t address); | ||
92 | |||
93 | #endif | ||