aboutsummaryrefslogtreecommitdiff
path: root/stm-fpgacfg.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-02-22 14:11:12 -0500
committerPaul Selkirk <paul@psgd.org>2017-02-22 17:45:31 -0500
commit189df371631a2b7bef91803d449e47470ad6a7bf (patch)
tree1986828d38cdd6507c96640f6370b433be720892 /stm-fpgacfg.c
parent56fcfdf3bec384a74eb9deb070f342142bbacff3 (diff)
Refactor flash code.
Diffstat (limited to 'stm-fpgacfg.c')
-rw-r--r--stm-fpgacfg.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/stm-fpgacfg.c b/stm-fpgacfg.c
index 16c490b..10abc57 100644
--- a/stm-fpgacfg.c
+++ b/stm-fpgacfg.c
@@ -4,7 +4,7 @@
* Functions for accessing the FPGA config memory and controlling
* the low-level status of the FPGA (reset registers/reboot etc.).
*
- * Copyright (c) 2016, NORDUnet A/S All rights reserved.
+ * Copyright (c) 2016-2017, NORDUnet A/S All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -48,11 +48,6 @@ int fpgacfg_check_id()
int fpgacfg_write_data(uint32_t offset, const uint8_t *buf, const uint32_t len)
{
- if ((offset % N25Q128_SECTOR_SIZE) == 0)
- // first page in sector, need to erase sector
- if (! n25q128_erase_sector(&fpgacfg_ctx, offset / N25Q128_SECTOR_SIZE))
- return -4;
-
return n25q128_write_data(&fpgacfg_ctx, offset, buf, len);
}
@@ -97,14 +92,7 @@ int fpgacfg_check_done(void)
return (status == GPIO_PIN_SET);
}
-int fpgacfg_erase_sectors(int num)
+int fpgacfg_erase_sector(uint32_t sector_offset)
{
- if (num > N25Q128_NUM_SECTORS || num < 0) num = N25Q128_NUM_SECTORS;
- while (num) {
- if (! n25q128_erase_sector(&fpgacfg_ctx, num - 1)) {
- return -1;
- }
- num--;
- }
- return 1;
+ return n25q128_erase_sector(&fpgacfg_ctx, sector_offset);
}