diff --git a/examples/4.Communication/SRAM_SPI/ReadMe.txt b/examples/4.Communication/SRAM_SPI/ReadMe.txt deleted file mode 100644 index 6b23953880c..00000000000 --- a/examples/4.Communication/SRAM_SPI/ReadMe.txt +++ /dev/null @@ -1,24 +0,0 @@ - - SRAM_main - Project - ---------------------------------- - Developed with embedXcode - - Project SRAM_main - Created by Rei VILO on déc. 22, 2012 - Copyright © 2012 embedXcode.weebly.com - Licence CC = BY SA NC - - - References - ---------------------------------- - - - - embedXcode - ---------------------------------- - Embedded Computing Template on Xcode 4 - Copyright © Rei VILO, 2010-2012 - Licence CC = BY NC SA - http://embedXcode.weebly.com/ - diff --git a/examples/4.Communication/SRAM_SPI/SRAM.cpp b/examples/4.Communication/SRAM_SPI/SRAM.cpp deleted file mode 100644 index 057750e568a..00000000000 --- a/examples/4.Communication/SRAM_SPI/SRAM.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -// SRAM.cpp -// Library C++ code -// ---------------------------------- -// Developed with embedXcode -// http://embedXcode.weebly.com -// -// Project chipKIT_SRAM -// -// Created by Rei VILO, déc. 22, 2012 14:26 -// embedXcode.weebly.com -// -// -// Copyright © Rei VILO, 2012 -// Licence CC = BY NC SA -// -// See SRAM.cpp.h and ReadMe.txt for references -// - - -#include "SRAM.h" - -SRAM::SRAM(uint8_t pinChipSelect) { - _pinChipSelect = pinChipSelect; -} - -void SRAM::begin() { - pinMode(_pinChipSelect, OUTPUT); - setMode(SRAM_SEQUENCE_MODE); -} - -void SRAM::setMode(uint8_t mode) { - digitalWrite(_pinChipSelect, LOW); - SPI.transfer(SRAM_WRITE_STATUS); - SPI.transfer(mode); - digitalWrite(_pinChipSelect, HIGH); -} - -uint8_t SRAM::getMode() { - digitalWrite(_pinChipSelect, LOW); - SPI.transfer(SRAM_READ_STATUS); - uint8_t v = SPI.transfer(0); - digitalWrite(_pinChipSelect, HIGH); - return v; -} - -void SRAM::write(uint16_t address, uint8_t * data, uint16_t length) { - if (length>0) { - digitalWrite(_pinChipSelect, LOW); - SPI.transfer(SRAM_WRITE); - SPI.transfer(address >> 8); - SPI.transfer(address & 0xFF); - for (uint16_t j=0; j0) { - digitalWrite(_pinChipSelect, LOW); - SPI.transfer(SRAM_READ); - SPI.transfer(address >> 8); - SPI.transfer(address & 0xFF); - -#ifdef __MSP430G2553__ - /// - /// @note Surprisingly with the MSP430G2553, this seems to be required! - /// - data[0] = SPI.transfer(0); -#endif - - for (uint16_t j=0; j= 100) // Arduino 1.0 and 1.5 specific -#include "Arduino.h" -#elif defined(ARDUINO) && (ARDUINO < 100) // Arduino 23 specific -#include "WProgram.h" -#else // error -#error Platform not defined -#endif - -// Include application, user and local libraries -#include "SPI.h" -#include "SRAM.h" - -// Define variables and constants - -// Core library for code-sense -#include "Energia.h" - -// Include application, user and local libraries -#include "SPI.h" -#include "SRAM.h" - -// Define variables and constants -#if defined(__MSP430G2553__) -SRAM mySRAM(P1_4); // chip select on pin P1_4 -#elif defined(__LM4F120H5QR__) -SRAM mySRAM(PE_5); // chip select on pin PE_5 -#else -#error Board not supported -#endif - -const uint16_t MAX = 130; -uint8_t modulo = 26; -char buffer[MAX]; -uint8_t i = 'A'; - -void setup (void) -{ - /// - /// @note SPI speed difference - /// * SPI_CLOCK_DIV2 for MSP430G2553 gives 8 MHz - /// * SPI_CLOCK_DIV2 for LM4F120H5QR gives 4 MHz! - /// - /// @warning SPI maximum speed - /// * SPI_CLOCK_DIV8 for MSP430G2553 - /// * SPI_CLOCK_DIV2 for LM4F120H5QR - /// - -#if defined(__MSP430G2553__) - SPI.begin(); - // SPI.setClockDivider(SPI_CLOCK_DIV2); // for MSP430G2553 DIV2 = 8 MHz - SPI.setClockDivider(SPI_CLOCK_DIV8); // for MSP430G2553 -#elif defined(__LM4F120H5QR__) - SPI.begin(2); - SPI.setClockDivider(SPI_CLOCK_DIV2); // for LM4F120H5QR = 4 MHz ! -#endif - - mySRAM.begin(); - - // For the example - Serial.begin (9600); - Serial.println("*** start"); - Serial.println("*** PUSH2 to close serial"); - Serial.println(); - - if (MAX < modulo) modulo = MAX; - pinMode(PUSH2, INPUT_PULLUP); - - Serial.print(" :"); - for (uint8_t j=0; j0) ) Serial.print((j+1)/100, DEC); - else Serial.print(" "); - } - Serial.println(); - - Serial.print(" :"); - for (uint8_t j=0; j"); - for (uint8_t j=0; jmodulo+'A') i = 'A'; - - mySRAM.write(100, (uint8_t *) buffer, sizeof buffer); - - for (uint8_t j=0; j