@@ -37,7 +37,7 @@ static void RAMFUNCTION flash_set_waitstates(unsigned int waitstates)
3737 while ((FLASH_ACR & FLASH_ACR_LATENCY_MASK ) != waitstates );
3838}
3939
40- static void RAMFUNCTION hal_flash_wait_complete (void )
40+ void RAMFUNCTION hal_flash_wait_complete (uint8_t bank )
4141{
4242 while ((FLASH_SR & FLASH_SR_BSY ) == FLASH_SR_BSY )
4343 ;
@@ -48,7 +48,7 @@ static void RAMFUNCTION hal_flash_wait_complete(void)
4848
4949}
5050
51- static void RAMFUNCTION hal_flash_wait_buffer_empty (void )
51+ static void RAMFUNCTION hal_flash_wait_buffer_empty (uint8_t bank )
5252{
5353 while ((FLASH_SR & FLASH_SR_DBNE ) == FLASH_SR_DBNE )
5454 ;
@@ -96,7 +96,7 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
9696 dst [i >> 2 ] = dword [0 ];
9797 ISB ();
9898 dst [(i >> 2 ) + 1 ] = dword [1 ];
99- hal_flash_wait_complete ();
99+ hal_flash_wait_complete (0 );
100100 if ((* sr & FLASH_SR_EOP ) != 0 )
101101 * sr |= FLASH_SR_EOP ;
102102 * cr &= ~FLASH_CR_PG ;
@@ -110,7 +110,7 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
110110
111111void RAMFUNCTION hal_flash_unlock (void )
112112{
113- hal_flash_wait_complete ();
113+ hal_flash_wait_complete (0 );
114114 if ((FLASH_CR & FLASH_CR_LOCK ) != 0 ) {
115115 FLASH_KEYR = FLASH_KEY1 ;
116116 DMB ();
@@ -123,14 +123,14 @@ void RAMFUNCTION hal_flash_unlock(void)
123123
124124void RAMFUNCTION hal_flash_lock (void )
125125{
126- hal_flash_wait_complete ();
126+ hal_flash_wait_complete (0 );
127127 if ((FLASH_CR & FLASH_CR_LOCK ) == 0 )
128128 FLASH_CR |= FLASH_CR_LOCK ;
129129}
130130
131131void RAMFUNCTION hal_flash_opt_unlock (void )
132132{
133- hal_flash_wait_complete ();
133+ hal_flash_wait_complete (0 );
134134 if ((FLASH_OPTCR & FLASH_OPTCR_OPTLOCK ) != 0 ) {
135135 FLASH_OPTKEYR = FLASH_OPTKEY1 ;
136136 DMB ();
@@ -145,7 +145,7 @@ void RAMFUNCTION hal_flash_opt_unlock(void)
145145void RAMFUNCTION hal_flash_opt_lock (void )
146146{
147147 FLASH_OPTCR |= FLASH_OPTCR_OPTSTRT ;
148- hal_flash_wait_complete ();
148+ hal_flash_wait_complete (0 );
149149 if ((FLASH_OPTCR & FLASH_OPTCR_OPTLOCK ) == 0 )
150150 FLASH_OPTCR |= FLASH_OPTCR_OPTLOCK ;
151151}
@@ -187,7 +187,7 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
187187 FLASH_CR = reg ;
188188 DMB ();
189189 FLASH_CR |= FLASH_CR_STRT ;
190- hal_flash_wait_complete ();
190+ hal_flash_wait_complete (0 );
191191 }
192192 /* If the erase operation is completed, disable the associated bits */
193193 FLASH_CR &= ~FLASH_CR_SER ;
@@ -446,8 +446,8 @@ int hal_flash_otp_write(uint32_t flashAddress, const void* data, uint16_t length
446446 return -1 ;
447447 }
448448
449- hal_flash_wait_complete ();
450- hal_flash_wait_buffer_empty ();
449+ hal_flash_wait_complete (0 );
450+ hal_flash_wait_buffer_empty (0 );
451451 hal_flash_unlock ();
452452 hal_flash_clear_errors (0 );
453453
@@ -456,7 +456,7 @@ int hal_flash_otp_write(uint32_t flashAddress, const void* data, uint16_t length
456456 length = (length / 2 * 2 );
457457
458458 while (idx < length && flashAddress <= FLASH_OTP_END - 1 ) {
459- hal_flash_wait_complete ();
459+ hal_flash_wait_complete (0 );
460460 /* Set PG bit */
461461 FLASH_CR |= FLASH_CR_PG ;
462462 /* Program an OTP word (32 bits) */
0 commit comments