From: Kevin Townsend Date: Sun, 2 Oct 2011 18:30:51 +0000 (+0200) Subject: SPI flash and makefile updated X-Git-Url: http://git.rohieb.name/hackover2013-badge-firmware.git/commitdiff_plain/c104c5fa180ae64a097335f5b7124dca244a13e3 SPI flash and makefile updated --- diff --git a/ChangeLog.txt b/ChangeLog.txt index 0cb02bc..73bb2e2 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,6 +2,10 @@ v0.9.8 - Ongoing ================ - Added driver for Sharp Memory Display /drivers/lcd/bitmap/sharpmem +- Added SPI Flash example + /tools/examples/spiflash/* +- Added write function to SPI Flash driver + /drivers/spiflash/* v0.9.5 - 3 August 2011 ====================== diff --git a/Makefile b/Makefile index 46c1220..3f71b77 100644 --- a/Makefile +++ b/Makefile @@ -98,6 +98,10 @@ OBJS += pn532.o VPATH += drivers/sensors/tcs3414 drivers/sensors/tsl2561 OBJS += tcs3414.o tsl2561.o +# SPI Flash +VPATH += drivers/spiflash/w25q16bv +OBJS += w25q16bv.o + ########################################################################## # Library files ########################################################################## diff --git a/build/codelite/LPC1343 Workspace.tags b/build/codelite/LPC1343 Workspace.tags index 9773273..d64d744 100644 Binary files a/build/codelite/LPC1343 Workspace.tags and b/build/codelite/LPC1343 Workspace.tags differ diff --git a/build/codelite/LPC1343 Workspace.workspace.session b/build/codelite/LPC1343 Workspace.workspace.session index 413664f..df01b19 100644 --- a/build/codelite/LPC1343 Workspace.workspace.session +++ b/build/codelite/LPC1343 Workspace.workspace.session @@ -1,18 +1,24 @@ - + - - + + - - + + + + + + + + diff --git a/build/codelite/LPC1343_CodeBase.project b/build/codelite/LPC1343_CodeBase.project index 1deddee..96405f8 100644 --- a/build/codelite/LPC1343_CodeBase.project +++ b/build/codelite/LPC1343_CodeBase.project @@ -234,6 +234,13 @@ + + + + + + + diff --git a/build/crossworks/LPC1343_CodeBase.hzs b/build/crossworks/LPC1343_CodeBase.hzs index 3193043..fea48a7 100644 --- a/build/crossworks/LPC1343_CodeBase.hzs +++ b/build/crossworks/LPC1343_CodeBase.hzs @@ -33,10 +33,6 @@ - - - - @@ -56,10 +52,10 @@ - - - + + + @@ -72,7 +68,7 @@ - + diff --git a/drivers/lcd/tft/drawing.c b/drivers/lcd/tft/drawing.c index a6701ab..e90a8e6 100644 --- a/drivers/lcd/tft/drawing.c +++ b/drivers/lcd/tft/drawing.c @@ -350,7 +350,7 @@ void drawString(uint16_t x, uint16_t y, uint16_t color, const FONT_INFO *fontInf // Send individual characters // We need to manually calculate width in pages since this is screwy with variable width fonts //uint8_t heightPages = charWidth % 8 ? charWidth / 8 : charWidth / 8 + 1; - drawCharBitmap(currentX, y, color, &fontInfo->data[charOffset], charWidth, fontInfo->height); + drawCharBitmap(currentX, y, color, (const char *)(&fontInfo->data[charOffset]), charWidth, fontInfo->height); // next char X currentX += charWidth + 1; diff --git a/drivers/spiflash/w25q16bv/w25q16bv.c b/drivers/spiflash/w25q16bv/w25q16bv.c index 909d864..7146938 100644 --- a/drivers/spiflash/w25q16bv/w25q16bv.c +++ b/drivers/spiflash/w25q16bv/w25q16bv.c @@ -241,8 +241,6 @@ void spiflashWriteEnable (bool enable) { if (!_w25q16bvInitialised) spiflashInit(); - uint32_t i; - // ToDo: Put the WP pin in an appropriate state if required W25Q16BV_SELECT(); @@ -519,9 +517,7 @@ spiflashError_e spiflashEraseChip (void) spiflashError_e spiflashWritePage (uint32_t address, uint8_t *buffer, uint32_t len) { uint8_t status; - uint32_t currentpage, totalpages; - uint32_t a, i, timeout; - a = i = 0; + uint32_t i; if (!_w25q16bvInitialised) spiflashInit(); diff --git a/main.c b/main.c index d0dd354..8b75435 100644 --- a/main.c +++ b/main.c @@ -47,6 +47,28 @@ #include "core/cmd/cmd.h" #endif +/**************************************************************************/ +/*! + Approximates a 1 millisecond delay using "nop". This is less + accurate than a dedicated timer, but is useful in certain situations. + + The number of ticks to delay depends on the optimisation level set + when compiling (-O). Depending on the compiler settings, one of the + two defined values for 'delay' should be used. +*/ +/**************************************************************************/ +void delayms(uint32_t ms) +{ + uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 45); // Release Mode (-Os) + // uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 120); // Debug Mode (No optimisations) + + while (delay > 0) + { + __asm volatile ("nop"); + delay--; + } +} + /**************************************************************************/ /*! Main program entry point. After reset, normal code execution will