From 26bd030c53539384f72717306b4f43e604d15a72 Mon Sep 17 00:00:00 2001 From: Bruno Vetel Date: Wed, 6 Feb 2008 01:58:02 +0100 Subject: [PATCH] Fix lock unlock --- main.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/main.cpp b/main.cpp index 8fd399a..b2b53d5 100644 --- a/main.cpp +++ b/main.cpp @@ -49,7 +49,6 @@ const char *menu_dataflash = { "6: Lock the flash\n\r" "7: Unlock the flash\r\n" "8: Read the lock register status of the flash\r\n" - "9: clear the lock register of the flash\r\n" }; //* Globales variables @@ -513,12 +512,26 @@ unsigned char enable_lock_unlock_cmd[4]= 0x3D,0x2A,0x7F,0xA9 }; +unsigned char disable_lock_unlock_cmd[4]= +{ + 0x3D,0x2A,0x7F,0x9A +}; void flash_lock_reg() { unsigned char rxf[4]; unsigned char rx[33]; int i; + clear_lock_reg(); + + clear_desc(&desc); + + desc.tx_cmd_pt = enable_lock_unlock_cmd; + desc.rx_cmd_pt = rxf; + desc.tx_cmd_size = 4; + desc.rx_cmd_size = 4; + + AT91F_SpiWrite(&desc); clear_desc(&desc); for ( i = 0 ; i < 32 ; i++) @@ -536,20 +549,8 @@ void flash_lock_reg() AT91F_SpiWrite(&desc); - clear_desc(&desc); - - desc.tx_cmd_pt = enable_lock_unlock_cmd; - desc.rx_cmd_pt = rxf; - desc.tx_cmd_size = 4; - desc.rx_cmd_size = 4; - - AT91F_SpiWrite(&desc); } -unsigned char disable_lock_unlock_cmd[4]= -{ - 0x3D,0x2A,0x7F,0x9A -}; void flash_unlock_reg() { -- 2.11.4.GIT