From 614c45044ede1bd224480630a2225d65818b8339 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Wed, 13 Feb 2013 18:27:46 -0700 Subject: [PATCH] test program for SPI flash programming --- firmware/spiflash/Makefile | 32 ++++++++++++++++++++++ firmware/spiflash/README | 1 + firmware/spiflash/spiflash.c | 52 ++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 firmware/spiflash/Makefile create mode 100644 firmware/spiflash/README create mode 100644 firmware/spiflash/spiflash.c diff --git a/firmware/spiflash/Makefile b/firmware/spiflash/Makefile new file mode 100644 index 00000000..3c219c62 --- /dev/null +++ b/firmware/spiflash/Makefile @@ -0,0 +1,32 @@ +# Hey Emacs, this is a -*- makefile -*- +# +# Copyright 2012 Michael Ossmann +# Copyright 2012 Jared Boone +# +# This file is part of HackRF. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +BINARY = spiflash + +SRC = $(BINARY).c \ + ../common/hackrf_core.c \ + ../common/si5351c.c \ + ../common/max2837.c \ + ../common/w25q80bv.c + +include ../common/Makefile_inc.mk diff --git a/firmware/spiflash/README b/firmware/spiflash/README new file mode 100644 index 00000000..088abd77 --- /dev/null +++ b/firmware/spiflash/README @@ -0,0 +1 @@ +This is a test program for SPI flash programming. diff --git a/firmware/spiflash/spiflash.c b/firmware/spiflash/spiflash.c new file mode 100644 index 00000000..1f0c4b6f --- /dev/null +++ b/firmware/spiflash/spiflash.c @@ -0,0 +1,52 @@ +/* + * Copyright 2010 - 2012 Michael Ossmann + * + * This file is part of HackRF. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include + +#include "hackrf_core.h" +#include "w25q80bv.h" + +int main(void) +{ + int i; + pin_setup(); + + /* Set 1V8 */ + gpio_set(PORT_EN1V8, PIN_EN1V8); + + /* program a test page to SPI flash */ + w25q80bv_setup(); + w25q80bv_page_program(); + + /* blink LED1 and LED3 */ + while (1) + { + gpio_set(PORT_LED1_3, (PIN_LED1|PIN_LED3)); /* LEDs on */ + for (i = 0; i < 2000000; i++) /* Wait a bit. */ + __asm__("nop"); + gpio_clear(PORT_LED1_3, (PIN_LED1|PIN_LED3)); /* LED off */ + for (i = 0; i < 2000000; i++) /* Wait a bit. */ + __asm__("nop"); + } + + return 0; +}