MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / write

Function write

bsp/mm32f526x/drivers/drv_flash.c:48–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48static int write(long offset, const uint8_t *buf, size_t size)
49{
50 size_t i;
51 uint32_t addr = OCFLASH_ADDR + offset;
52
53 FLASH->KEYR = 0x45670123;
54 FLASH->KEYR = 0xCDEF89AB;
55 FLASH->SR = 0x00000001 | 0x00000004 | 0x00000010;
56 FLASH->CR |= 0x1;
57
58 i = 0;
59 while (i < size)
60 {
61 *(__IO uint16_t *)addr = *buf | *(buf + 1) << 8;
62 addr = addr + 2;
63 buf += 2;
64 i += 2;
65 }
66 //Lock flash
67 FLASH->CR |= 0x00000080;
68
69 return size;
70}
71
72static int erase(long offset, size_t size)
73{

Callers 15

handle_nmiFunction · 0.50
handle_trapFunction · 0.50
_exitFunction · 0.50
write_hexFunction · 0.50
rt_init_thread_entryFunction · 0.50
chargen_threadFunction · 0.50
fsrw1_thread_entryFunction · 0.50
fsrw2_thread_entryFunction · 0.50
_setup_file_contentFunction · 0.50
_setup_file_contentFunction · 0.50
_setup_file_contentFunction · 0.50
rtlink_fwriteFunction · 0.50

Calls

no outgoing calls

Tested by 3

fsrw1_thread_entryFunction · 0.40
fsrw2_thread_entryFunction · 0.40
send_commFunction · 0.40