Skip to content

Commit

Permalink
fx3_firmware: Perform "warm" GPIO config when enabling flash access
Browse files Browse the repository at this point in the history
This fixes issue #196.

A "warm" IO reconfiguration is required, otherwise the FPGA's nConfig
will be reset to a default of CyFalse (resetting the FPGA).

Additionally, the firmware.c and associated functions have been renamed;
these are flash-related functions in general -- the "Firmware" name was
misleading.
  • Loading branch information
jynik committed Jan 14, 2014
1 parent e5dcfe4 commit da81c2a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions fx3_firmware/bladeRF.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "cyu3gpio.h"
#include "pib_regs.h"

#include "firmware.h"
#include "flash.h"
#include "spi_flash_lib.h"
#include "rf.h"
#include "fpga.h"
Expand Down Expand Up @@ -538,7 +538,7 @@ CyBool_t NuandHandleVendorRequest(

case BLADE_USB_CMD_JUMP_TO_BOOTLOADER:
StopApplication();
NuandFirmwareStart();
NuandFlashInit();

// Erase the first sector so we can write the bootloader
// header
Expand Down Expand Up @@ -690,7 +690,7 @@ void CyFxbladeRFApplnUSBEventCB (CyU3PUsbEventType_t evtype, uint16_t evdata)
switch(glUsbAltInterface) {
case USB_IF_CONFIG: NuandFpgaConfig.stop() ; break ;
case USB_IF_RF_LINK: NuandRFLink.stop(); break ;
case USB_IF_SPI_FLASH: NuandFirmwareStop(); break ;
case USB_IF_SPI_FLASH: NuandFlashDeinit(); break ;
default: break ;
}

Expand All @@ -700,7 +700,7 @@ void CyFxbladeRFApplnUSBEventCB (CyU3PUsbEventType_t evtype, uint16_t evdata)
} else if (alt_interface == USB_IF_RF_LINK) {
NuandRFLink.start();
} else if (alt_interface == USB_IF_SPI_FLASH) {
NuandFirmwareStart();
NuandFlashInit();
}
glUsbAltInterface = alt_interface;
break;
Expand Down Expand Up @@ -748,7 +748,7 @@ static void extractSerialAndCal(void)
char serial_buf[32];
int i;

NuandFirmwareStart();
NuandFlashInit();

status = NuandReadOtp(0, 0x100, otp_buf);

Expand All @@ -769,7 +769,7 @@ static void extractSerialAndCal(void)
glAutoLoadValid = CyTrue;
}

NuandFirmwareStop();
NuandFlashDeinit();
}

void bladeRFInit(void)
Expand Down
8 changes: 4 additions & 4 deletions fx3_firmware/firmware.c → fx3_firmware/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "firmware.h"
#include <string.h>
#include "cyu3spi.h"
#include "cyu3error.h"
#include "bladeRF.h"
#include "spi_flash_lib.h"
#include "flash.h"

static CyU3PReturnStatus_t FlashReadStatus(uint8_t *val)
{
Expand Down Expand Up @@ -115,17 +115,17 @@ CyU3PReturnStatus_t NuandWriteOtp(size_t offset, size_t size, void *buf) {
return status;
}

void NuandFirmwareStart() {
void NuandFlashInit() {
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

NuandGPIOReconfigure(CyFalse, CyFalse);
NuandGPIOReconfigure(CyFalse, CyTrue);

status = CyFxSpiInit();

glAppMode = MODE_FW_CONFIG;
}

void NuandFirmwareStop() {
void NuandFlashDeinit() {
CyFxSpiDeInit();
}

Expand Down
4 changes: 2 additions & 2 deletions fx3_firmware/firmware.h → fx3_firmware/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ CyU3PReturnStatus_t NuandReadOtp(size_t offset, size_t size, void *buf);
CyU3PReturnStatus_t NuandWriteOtp(size_t offset, size_t size, void *buf);
CyU3PReturnStatus_t NuandLockOtp();

void NuandFirmwareStart();
void NuandFirmwareStop();
void NuandFlashInit();
void NuandFlashDeinit();

int NuandExtractField(char *ptr, int len, char *field,
char *val, size_t maxlen);
Expand Down

0 comments on commit da81c2a

Please sign in to comment.