Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SPI_Demo_Nano by
Revision 1:b625bd197a22, committed 2015-02-25
- Comitter:
- tsh
- Date:
- Wed Feb 25 19:48:28 2015 +0000
- Parent:
- 0:5810870d2b29
- Commit message:
- Remove main, to use as library
Changed in this revision
| main.cpp | Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 22 05:08:52 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
-
-Copyright (c) 2012-2014 RedBearLab
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-and associated documentation files (the "Software"), to deal in the Software without restriction,
-including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
-FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-
-#include "mbed.h"
-#include "spi_master.h"
-
-DigitalOut spi_cs(P0_7);
-
-SPIClass SPI1(NRF_SPI1);
-
-Serial pc(USBTX, USBRX);
-
-void Flash_Buff_WriteBytes(uint16_t addr, uint8_t *pbuf, uint16_t len)
-{
- uint16_t index;
-
- spi_cs = 0;
- wait_us(200);
-
- SPI1.transfer(0x84);
- SPI1.transfer(0x00);
- SPI1.transfer((uint8_t)(addr>>8));
- SPI1.transfer((uint8_t)addr);
- for(index=0; index<len; index++)
- {
- SPI1.transfer(*pbuf);
- pbuf++;
- }
-
- wait_us(200);
- spi_cs = 1;
-}
-
-void Flash_Buff_ReadBytes(uint16_t addr, uint8_t *pbuf, uint16_t len)
-{
- uint16_t index;
-
- spi_cs = 0;
- wait_us(200);
-
- SPI1.transfer(0xD1);
- SPI1.transfer(0x00);
- SPI1.transfer((uint8_t)(addr>>8));
- SPI1.transfer((uint8_t)addr);
- for(index=0; index<len; index++)
- {
- *pbuf = SPI1.transfer(0x00);
- pbuf++;
- }
-
- wait_us(200);
- spi_cs = 1;
-}
-
-uint8_t i;
-uint8_t wt_buf[7] = {'H','e','l','l', 'o', '\r', '\n'};
-uint8_t rd_buf[7];
-
-int main(void)
-{
- pc.baud(9600);
- wait(8);
- spi_cs = 1;
- pc.printf("SPI Demo Start \r\n");
-
- //SPI1.begin();
- SPI1.begin(P0_6, P0_15, P0_29);//SCK, MOSI, MOSI
-
- wait(1);
- Flash_Buff_WriteBytes(0, wt_buf, 7);
- while(1)
- {
- memset(rd_buf, 0x00, 7);
- Flash_Buff_ReadBytes(0, rd_buf, 7);
- for(i=0; i<7; i++)
- pc.putc(rd_buf[i]);
- wait(1);
- }
-}
-
-
-
-
-
-
-
--- a/mbed.bld Wed Oct 22 05:08:52 2014 +0000 +++ b/mbed.bld Wed Feb 25 19:48:28 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file
