File tree Expand file tree Collapse file tree
tmk_core/common/arm_atsam Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 * You should have received a copy of the GNU General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
16-
16+ #include "samd51j18a.h"
1717#include "eeprom.h"
18+ #include "core_cm4.h"
19+ #include "component/nvmctrl.h"
1820
1921#define EEPROM_SIZE 32
2022
21- static uint8_t buffer [EEPROM_SIZE ];
23+ volatile uint8_t * SmartEEPROM8 = (uint8_t * ) 0x44000000 ;
24+ uint8_t buffer [EEPROM_SIZE ];
2225
2326uint8_t eeprom_read_byte (const uint8_t * addr ) {
2427 uintptr_t offset = (uintptr_t )addr ;
25- return buffer [offset ];
28+
29+ if (NVMCTRL -> SEESTAT .bit .PSZ == 0 || NVMCTRL -> SEESTAT .bit .SBLK == 0 )
30+ return buffer [offset ];
31+
32+ int timeout = 10000 ;
33+ while (NVMCTRL -> SEESTAT .bit .BUSY && timeout -- > 0 )
34+ ;
35+ return SmartEEPROM8 [offset ];
2636}
2737
2838void eeprom_write_byte (uint8_t * addr , uint8_t value ) {
2939 uintptr_t offset = (uintptr_t )addr ;
30- buffer [offset ] = value ;
40+
41+ if (NVMCTRL -> SEESTAT .bit .PSZ == 0 || NVMCTRL -> SEESTAT .bit .SBLK == 0 ) {
42+ buffer [offset ] = value ;
43+ return ;
44+ }
45+
46+ int timeout = 10000 ;
47+ while (NVMCTRL -> SEESTAT .bit .BUSY && timeout -- > 0 )
48+ ;
49+
50+ SmartEEPROM8 [offset ] = value ;
3151}
3252
3353uint16_t eeprom_read_word (const uint16_t * addr ) {
You can’t perform that action at this time.
0 commit comments