arrangement

jd-update
flavienhaas 6 years ago
parent d5388c5d31
commit 6912a21909

Before

Width:  |  Height:  |  Size: 499 KiB

After

Width:  |  Height:  |  Size: 499 KiB

@ -1,24 +0,0 @@
#include <SPI.h>
#include "wiring_private.h" // pinPeripheral() function
SPIClass mySPI (&sercom2, 3, 5, 4, SPI_PAD_0_SCK_3, SERCOM_RX_PAD_1); //digital 3,5,4 for PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI
void setup() {
SerialUSB.begin(9600);
mySPI.begin(); //initiate the SPI communicaton
// Assign pins 3, 4, 5 to SERCOM & SERCOM_ALT
pinPeripheral(3, PIO_SERCOM_ALT);
pinPeripheral(4, PIO_SERCOM_ALT);
pinPeripheral(5, PIO_SERCOM);
}
uint8_t i=0;
void loop() {
mySPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
int recu = 0; //create recu
recu = mySPI.transfer(2); //send and recieve using spi
SerialUSB.println(recu);
mySPI.endTransaction();
delay(100);
}

@ -1,25 +0,0 @@
#include <SPI.h>
#include "wiring_private.h" // pinPeripheral() function
SPIClass mySPI (&sercom2, 3, 5, 4, SPI_PAD_0_SCK_3, SERCOM_RX_PAD_1); //digital 3,5,4 for PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI
void setup() {
SerialUSB.begin(9600);
// do this first, for Reasons
mySPI.begin();
// Assign pins 3, 4, 5 to SERCOM & SERCOM_ALT
pinPeripheral(3, PIO_SERCOM_ALT);
pinPeripheral(4, PIO_SERCOM_ALT);
pinPeripheral(5, PIO_SERCOM);
}
uint8_t i=0;
void loop() {
SerialUSB.println("je SPI");
mySPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
mySPI.transfer(1);
mySPI.endTransaction();
delay(100);
}

@ -1,66 +0,0 @@
#include <SPI.h>
void setup (void)
{
Serial.begin (115200);
Serial.println ();
digitalWrite(SS, HIGH); // ensure SS stays high for now
SPI.begin ();
// Slow down the master a bit
SPI.setClockDivider(SPI_CLOCK_DIV8);
} // end of setup
byte transferAndWait (const byte what)
{
byte a = SPI.transfer (what);
delayMicroseconds (20);
return a;
} // end of transferAndWait
void loop (void)
{
byte a, b, c, d;
// enable Slave Select
digitalWrite(SS, LOW);
transferAndWait ('a'); // add command
transferAndWait (10);
a = transferAndWait (17);
b = transferAndWait (33);
c = transferAndWait (42);
d = transferAndWait (0);
// disable Slave Select
digitalWrite(SS, HIGH);
Serial.println ("Adding results:");
Serial.println (a, DEC);
Serial.println (b, DEC);
Serial.println (c, DEC);
Serial.println (d, DEC);
// enable Slave Select
digitalWrite(SS, LOW);
transferAndWait ('s'); // subtract command
transferAndWait (10);
a = transferAndWait (17);
b = transferAndWait (33);
c = transferAndWait (42);
d = transferAndWait (0);
// disable Slave Select
digitalWrite(SS, HIGH);
Serial.println ("Subtracting results:");
Serial.println (a, DEC);
Serial.println (b, DEC);
Serial.println (c, DEC);
Serial.println (d, DEC);
delay (1000); // 1 second delay
} // end of loop

@ -1,46 +0,0 @@
/*
* Pins: -> D10 : SS (Slave Select)
* -> D11 : MOSI (Master Out Slave In) (Communication maitre -> esclave)
* -> D12 : MISO (Master In Slave Out) (Communication esclave -> maitre)
* -> D13 : SCLK (Serial Clock)
* Informations : -> Si la pin SS n'est pas configuré en mode OUTPUT, le périphérique
* sera considéré comme un esclave.
* -> Ici, pas besoin de définir une pin SS car c'est un esclave
*
*/
// Inclusion des bibliothèques
#include <SPI.h>
//Variables
const int MOSI_PIN = 11;
const int MISO_PIN = 12;
const int SCLK_PIN = 13;
void setup()
{
// Configuration des pins du SPI
pinMode(MOSI_PIN,INPUT);
pinMode(MISO_PIN,OUTPUT);
pinMode(SCLK_PIN,INPUT);
// Initialisation du port série
Serial.begin(9600);
// Initialisation du bus SPI
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV4); // Diviseur d'horloge du bus SPI (choisir la fréquence de l'horloge en quart de l'horloge du microcontroleur)
//SPI.setBitOrder(MSBFIRST); // Sens d'envoi des bits (most significant bit first)
//SPI.setDataMode(SPI_MODE0); // Mode de transmission des données (parité ety phase de l'horloge)
}
void loop()
{
// Transmettre des informations
byte incomingByte = 0x0;
incomingByte = SPI.transfer(0x0); // se qu'on recois = transfert(ce qu'on transmet)
Serial.println(incomingByte,HEX);
delay(1000);
}

@ -1,18 +0,0 @@
#include <SPI.h>
#define ss 10
void setup() {
SerialUSB.begin(9600);
pinMode(ss, OUTPUT);
SPI.begin(); //initiate the SPI communicaton
SPI.setBitOrder(MSBFIRST);
}
void loop() {
digitalWrite(ss, LOW);
SPI.transfer(0x02);
digitalWrite(ss, HIGH);
SerialUSB.println("0x02 sent");
SPI.endTransaction();
delay(1000);
}

@ -1,5 +0,0 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://arduino.stackexchange.com/questions/36663/communication-between-genuino-zero-and-arduino-uno-using-uart

@ -1,5 +0,0 @@
Genuino Zero (RX) pin 0 ---------------- Arduino Uno pin 11
Genuino Zero (TX) pin1 ---------------- Arduino Uno pin 10
Ground ---------------------------------- Ground

@ -1,47 +0,0 @@
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
/* Use a variable called byteRead to temporarily store
the data coming from the computer */
byte byteRead;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
char a[8];
/* check if data has been sent from the computer: */
if (Serial.available())
{
/* read the most recent byte */
byteRead = Serial.read();
//a[0] = atoi(byteRead);
//a[1] = atoi(byteRead);
Serial.print("rushin\r\n");
/*ECHO the value that was read, back to the serial port. */
if(byteRead == 0x61)
{
digitalWrite(LED_BUILTIN, HIGH);
Serial.write(byteRead);
}
}
if (mySerial.available())
{
/* read the most recent byte */
byteRead = mySerial.read();
//a[0] = atoi(byteRead);
// a[1] = atoi(byteRead);
mySerial.print("rushin\r\n");
/*ECHO the value that was read, back to the serial port. */
if(byteRead == 0x61)
{
digitalWrite(LED_BUILTIN, HIGH);
mySerial.write(byteRead);
}
}
}

@ -1,21 +0,0 @@
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 7;
void setup() {
Serial.begin(9600);
pinMode(pushButton, INPUT);
}
void loop() {
int buttonState = digitalRead(pushButton);
//if(buttonState == 1)
//{
Serial.println("a");
//}
delay(1000);
}

@ -1,36 +0,0 @@
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)
*/
char mavar[7]="bonjour";
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
//Serial.println("Goodnight moon!");
mySerial.begin(4800); // set the data rate for the SoftwareSerial port
mySerial.println("je suis la station");
}
void loop() {
if (mySerial.available()) {
Serial.write(mavar);
}
}

@ -1,37 +0,0 @@
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)
*/
char mavar[7];
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
//Serial.println("Goodnight moon!");
mySerial.begin(4800); // set the data rate for the SoftwareSerial port
mySerial.println("je suis la passerelle");
}
void loop() {
if (mySerial.available()) {
mavar = mySerial.read();
}
Serial.println(mavar);
}
Loading…
Cancel
Save