Skip to content

Commit c328b3f

Browse files
authored
Merge pull request ARMmbed#72 from ARMmbed/flash_api_source
Changed flash API to using C source code
2 parents 7d1e0b3 + 92d5d5d commit c328b3f

File tree

5 files changed

+61
-57
lines changed

5 files changed

+61
-57
lines changed

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/PinNames.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ typedef enum {
113113
LED2 = PIN_01,
114114
LED3 = PIN_02,
115115

116+
LED_RED = LED1,
117+
LED_YELLOW = LED2,
118+
LED_GREEN = LED3,
119+
116120
// UART0
117121
USBTX = PIN_55,
118122
USBRX = PIN_57,
Lines changed: 44 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2017 ARM Limited
2+
* Copyright (c) 2018 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,71 +13,59 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
17+
#if DEVICE_FLASH
1618

19+
#include "stdbool.h"
20+
#include "ti/devices/cc32xx/inc/hw_types.h"
1721
#include "flash_api.h"
18-
#include "flash_data.h"
19-
#include "critical.h"
22+
#include "ti/devices/cc32xx/driverlib/flash.h"
2023

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)
2228

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+
}
2444

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+
}
5550

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+
}
6455

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+
}
6860

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+
}
7665

77-
void flash_set_target_config(flash_t *obj)
66+
uint32_t flash_get_size(const flash_t *obj)
7867
{
79-
obj->flash_algo = &flash_algo_config;
80-
obj->target_config = &flash_target_config;
68+
return CC3200_FLASH_SIZE;
8169
}
8270

8371
#endif

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/objects.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ struct trng_s {
7878
uint32_t placeholder;
7979
};
8080

81+
struct flash_s {
82+
uint32_t placeholder;
83+
};
84+
8185
typedef struct spi_clock_config_s {
8286

8387
//! \param ulSPIClk is the rate of clock supplied to the SPI module.

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/spi_api.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, cha
283283
{
284284
spi_words = (tx_length >> 2);
285285
}
286+
else if (spi_inst->word_length == 8)
287+
{
288+
spi_words = tx_length;
289+
}
290+
286291
unsigned char *rx_temp = malloc(tx_length);
287292
SPITransfer(spi_inst->baseAddr, (unsigned char *)tx_buffer,
288293
(unsigned char *)rx_temp, (unsigned long) spi_words,
@@ -306,6 +311,10 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, cha
306311
{
307312
spi_words = (rx_length >> 2);
308313
}
314+
else if (spi_inst->word_length == 8)
315+
{
316+
spi_words = rx_length;
317+
}
309318

310319
unsigned char *tx_temp = malloc(rx_length);
311320
for (i = 0; i < tx_length; i ++)

targets/targets.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4487,7 +4487,6 @@
44874487
},
44884488
"CC3220SF": {
44894489
"inherits": ["CC32XX"],
4490-
"extra_labels": ["FLASH_CMSIS_ALGO"],
44914490
"device_has": ["USTICKER", "LPTICKER", "SERIAL", "SERIAL_FC", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "INTERRUPTIN", "SPI", "ANALOGIN", "FLASH", "TRNG"],
44924491
"core": "Cortex-M4",
44934492
"bootloader_supported": true

0 commit comments

Comments
 (0)