|
1 | 1 | /* mbed Microcontroller Library
|
2 |
| - * Copyright (c) 2017 ARM Limited |
| 2 | + * Copyright (c) 2018 ARM Limited |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
13 | 13 | * See the License for the specific language governing permissions and
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
| 16 | + |
| 17 | +#if DEVICE_FLASH |
16 | 18 |
|
| 19 | +#include "stdbool.h" |
| 20 | +#include "ti/devices/cc32xx/inc/hw_types.h" |
17 | 21 | #include "flash_api.h"
|
18 |
| -#include "flash_data.h" |
19 |
| -#include "critical.h" |
| 22 | +#include "ti/devices/cc32xx/driverlib/flash.h" |
20 | 23 |
|
21 |
| -// This file is automagically generated |
| 24 | +#define CC3200_FLASH_SECTOR_SIZE 0x800 |
| 25 | +#define CC3200_FLASH_PAGE_SIZE 0x4 |
| 26 | +#define CC3200_FLASH_START_ADDRESS 0x01000000 |
| 27 | +#define CC3200_FLASH_SIZE (1024*1024) |
22 | 28 |
|
23 |
| -#if DEVICE_FLASH |
| 29 | +int32_t flash_init(flash_t *obj) |
| 30 | +{ |
| 31 | + return 0; |
| 32 | +} |
| 33 | + |
| 34 | +int32_t flash_free(flash_t *obj) |
| 35 | +{ |
| 36 | + //FlashDisable(); |
| 37 | + return 0; |
| 38 | +} |
| 39 | + |
| 40 | +int32_t flash_erase_sector(flash_t *obj, uint32_t address) |
| 41 | +{ |
| 42 | + return FlashErase(address); |
| 43 | +} |
24 | 44 |
|
25 |
| -// This is a flash algo binary blob. It is PIC (position independent code) that should be stored in RAM |
26 |
| -static uint32_t FLASH_ALGO[] = { |
27 |
| - 0xd1fd3801, 0x49964770, 0x6e48b418, 0x0000f440, 0x4b946648, 0xf241681a, 0x380140d5, 0xf042d1fd, |
28 |
| - 0x60180010, 0x40d5f241, 0xd1fd3801, 0xf8d24a8e, 0xf040016c, 0xf8c2003c, 0x4b8c016c, 0xf0406c98, |
29 |
| - 0x64980001, 0x6480f44f, 0x6cd86820, 0x0001f040, 0xf04f64d8, 0xf8cd0c00, 0x9800c000, 0x90001c40, |
30 |
| - 0xd3fa2810, 0xf0206cd8, 0x64d80001, 0xf0206c98, 0x64980001, 0x68c0487e, 0x0ffff010, 0x487dd106, |
31 |
| - 0xc000f8c0, 0x40d5f241, 0xd1fd3801, 0x00c8f8d1, 0x2802b2c0, 0xf8d2d113, 0xf0200110, 0xf420000f, |
32 |
| - 0xf0406040, 0xf8c20002, 0xf8d20110, 0xf0200114, 0xf420000f, 0xf0406040, 0xf8c20002, 0xf8d20114, |
33 |
| - 0xf0400184, 0xf8c20002, 0x486b0184, 0xf3c06800, 0x280e5083, 0x00b0f8d1, 0x007cf420, 0xf440bf0c, |
34 |
| - 0xf4400048, 0xf8c10024, 0x486400b0, 0xf0236803, 0x60035380, 0xb2806820, 0xd2062802, 0x00a8f8d1, |
35 |
| - 0x0004f040, 0x00a8f8c1, 0x6820e022, 0xd01f0c00, 0x0188f8d2, 0x00e1f040, 0x0188f8c2, 0x68034858, |
36 |
| - 0x0f01f013, 0x6803d014, 0x0301f023, 0xf8d26003, 0xf4400188, 0xf8c27000, 0x48520188, 0xf0226802, |
37 |
| - 0x60020201, 0xf8c01d00, 0x1d00c000, 0xc000f8c0, 0x6800484d, 0xf3c00f02, 0x2a036003, 0xd22cd00f, |
38 |
| - 0x6800484a, 0x1080f3c0, 0x6a88b158, 0x0080f020, 0x69086288, 0x4070f020, 0x5080f040, 0xb9e0e01c, |
39 |
| - 0x6a48e7ee, 0x000ff020, 0x6070f420, 0x30c0f420, 0x0001f040, 0x60a0f440, 0x3080f440, 0x6a886248, |
40 |
| - 0x0080f020, 0x4070f020, 0x007ff420, 0x104cf440, 0x69086288, 0x4070f020, 0xbc186108, 0x0000f04f, |
41 |
| - 0x20004770, 0x48324770, 0x2201f640, 0x49316142, 0x68816081, 0x0f04f011, 0x68c0d1fb, 0xbf184010, |
42 |
| - 0x47702001, 0x2201f640, 0x614a4929, 0x482a6008, 0x68886088, 0x0f02f010, 0x68c8d1fb, 0xbf184010, |
43 |
| - 0x47702001, 0xf242b430, 0x4b216c01, 0xc014f8c3, 0xbf182900, 0xc084f8df, 0xf020d01e, 0x601c047f, |
44 |
| - 0xf000e00b, 0xf105057c, 0xf5054580, 0xf852257d, 0xf8c54b04, 0x1d004100, 0xf0101f09, 0xd1010f7c, |
45 |
| - 0xb90c6b1c, 0xd1ec2900, 0xc020f8c3, 0xf0146a1c, 0xd1fb0f01, 0xd1e02900, 0x2000bc30, 0x00004770, |
46 |
| - 0x4402f000, 0x4402fc18, 0x4402e000, 0x44025000, 0x4402d000, 0x4402f804, 0x4402dc78, 0x4402fc74, |
47 |
| - 0x4402fc20, 0x4402f818, 0x4402dc80, 0x4402f840, 0x400fd000, 0xa4420004, 0xa4420002, 0xa4420001, |
48 |
| - 0x00000004, 0x00000008, 0x00000014, 0x00000018, 0x00000024, 0x00000028, 0x00000030, 0x00000034, |
49 |
| - 0x00000040, 0x00000044, 0x00000048, 0x0000004c, 0x00000050, 0x00000054, 0x00000058, 0x0000005c, |
50 |
| - 0x00000060, 0x00000064, 0x00000068, 0x0000006c, 0x00000070, 0x00000074, 0x00000078, 0x0000007c, |
51 |
| - 0x00000080, 0x00000084, 0x00000088, 0x0000008c, 0x00000090, 0x00000094, 0x00000098, 0x0000009c, |
52 |
| - 0x000000a0, 0x000000a4, 0x000000a8, 0x000000ac, 0x000000b8, 0x000000bc, 0x000000c8, 0x000000cc, |
53 |
| - 0x000000d8, 0x000000dc, 0x00000000 |
54 |
| -}; |
| 45 | +int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size) |
| 46 | +{ |
| 47 | + return FlashProgram((unsigned long *)data, (unsigned long)address, |
| 48 | + (unsigned long)size); |
| 49 | +} |
55 | 50 |
|
56 |
| -static const flash_algo_t flash_algo_config = { |
57 |
| - .init = 0x7, |
58 |
| - .uninit = 0x1c3, |
59 |
| - .erase_sector = 0x1e5, |
60 |
| - .program_page = 0x205, |
61 |
| - .static_base = 0x348, |
62 |
| - .algo_blob = FLASH_ALGO |
63 |
| -}; |
| 51 | +uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address) |
| 52 | +{ |
| 53 | + return CC3200_FLASH_SECTOR_SIZE; |
| 54 | +} |
64 | 55 |
|
65 |
| -static const sector_info_t sectors_info[] = { |
66 |
| - {0x1000000, 0x800}, |
67 |
| -}; |
| 56 | +uint32_t flash_get_page_size(const flash_t *obj) |
| 57 | +{ |
| 58 | + return CC3200_FLASH_PAGE_SIZE; |
| 59 | +} |
68 | 60 |
|
69 |
| -static const flash_target_config_t flash_target_config = { |
70 |
| - .page_size = 0x400, |
71 |
| - .flash_start = 0x1000000, |
72 |
| - .flash_size = 0x100000, |
73 |
| - .sectors = sectors_info, |
74 |
| - .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) |
75 |
| -}; |
| 61 | +uint32_t flash_get_start_address(const flash_t *obj) |
| 62 | +{ |
| 63 | + return CC3200_FLASH_START_ADDRESS; |
| 64 | +} |
76 | 65 |
|
77 |
| -void flash_set_target_config(flash_t *obj) |
| 66 | +uint32_t flash_get_size(const flash_t *obj) |
78 | 67 | {
|
79 |
| - obj->flash_algo = &flash_algo_config; |
80 |
| - obj->target_config = &flash_target_config; |
| 68 | + return CC3200_FLASH_SIZE; |
81 | 69 | }
|
82 | 70 |
|
83 | 71 | #endif
|
0 commit comments