This repository was archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Added new features to tinyTILE-Extended-Support-Library. #5
Open
SidLeung
wants to merge
1
commit into
intel:master
Choose a base branch
from
SidLeung:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright (c) 2016 Intel Corporation. All rights reserved. | ||
| // See the bottom of this file for the license terms. | ||
|
|
||
| /* | ||
| * This sketch is to demonstrate I2C reading from a device, as a bus master. It first makes a request to | ||
| * read from the device. Then proceed with reading out one byte at a time and dump in onto the serial term | ||
| * for display, in hex. The sketch continue doing the above steps. If the read operation fails, please check | ||
| * the connection to the external device: verify the signals, make sure the board and the device share a | ||
| * common ground connection. | ||
| * | ||
| * Please note: | ||
| * 1. This sketch makes use of ARC_I2C1. One of the two I2C connections from the ARC core. For the QUARK core I2C | ||
| * connection, please refer to the quarkI2C library. | ||
| * 2. The ARC_I2C1 connections are not available in the Arduino 101 hardware platform. | ||
| * 3. The sketch is accessing an external I2C device with an device number (address) of 8. This address can be | ||
| * changed to fit your setup. | ||
| */ | ||
|
|
||
| #include <ARC_I2C1.h> | ||
|
|
||
| void setup() | ||
| { | ||
| Serial.begin(9600); // start serial for output | ||
| while(!Serial); // Wait here till serial terminal is ready/opened | ||
|
|
||
| ARC_I2C1.begin(); // join i2c bus | ||
| } | ||
|
|
||
| void loop() | ||
| { | ||
|
|
||
| int ret = ARC_I2C1.requestFrom(8, 20); // request 20 bytes from slave device #8 | ||
| if (ret == 0) | ||
| { | ||
| Serial.println("read from slave device failed"); | ||
| } | ||
|
|
||
| while (ARC_I2C1.available()) // slave may send less than requested | ||
| { | ||
| char c = ARC_I2C1.read(); // receive a byte as character | ||
| Serial.println(c, HEX); | ||
| } | ||
| delay(1000); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| Copyright (c) 2016 Intel Corporation. All rights reserved. | ||
|
|
||
| This library is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU Lesser General Public | ||
| License as published by the Free Software Foundation; either | ||
| version 2.1 of the License, or (at your option) any later version. | ||
|
|
||
| This library 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 | ||
| Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public | ||
| License along with this library; if not, write to the Free Software | ||
| Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
|
||
| */ | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Copyright (c) 2016 Intel Corporation. All rights reserved. | ||
| // See the bottom of this file for the license terms. | ||
|
|
||
| /* | ||
| * This sketch is to demonstrate I2C writing to a device, as a bus master. It first makes a request to | ||
| * write to the device. Then proceed with write out one byte annd completed the transmission. The sketch | ||
| * continues with these steps and increament the byte value each lap. If the write operation fails, please check | ||
| * the connection to the external device: verify the signals, make sure the board and the device share a | ||
| * common ground connection. | ||
| * | ||
| * Please note: | ||
| * 1. This sketch makes use of ARC_I2C1. One of the two I2C connections from the ARC core. For the QUARK core I2C | ||
| * connection, please refer to the quarkI2C library. | ||
| * 2. The ARC_I2C1 connections are not available in the Arduino 101 hardware platform. | ||
| * 3. The sketch is accessing an external I2C device with an device number (address) of 8. This address can be | ||
| * changed to fit your setup. | ||
| */ | ||
|
|
||
|
|
||
| #include <ARC_I2C1.h> | ||
|
|
||
| void setup() | ||
| { | ||
| Serial.begin(9600); // start serial for output | ||
| while(!Serial); // Wait here till serial terminal is ready/opened | ||
|
|
||
| ARC_I2C1.begin(); // join i2c bus | ||
| } | ||
|
|
||
| byte x = 1; | ||
| byte rdata; | ||
| void loop() | ||
| { | ||
| ARC_I2C1.beginTransmission(8); // transmit to device #8 | ||
| ARC_I2C1.write(x); // sends one byte | ||
| int result = ARC_I2C1.endTransmission(); // stop transmitting | ||
| if (result == 0) | ||
| { | ||
| Serial.print("x = "); | ||
| Serial.println(x); | ||
| } | ||
| else | ||
| { | ||
| Serial.print("transmit failed with error code "); | ||
| Serial.println(result); | ||
| } | ||
| x++; | ||
| delay(500); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| Copyright (c) 2016 Intel Corporation. All rights reserved. | ||
|
|
||
| This library is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU Lesser General Public | ||
| License as published by the Free Software Foundation; either | ||
| version 2.1 of the License, or (at your option) any later version. | ||
|
|
||
| This library 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 | ||
| Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public | ||
| License along with this library; if not, write to the Free Software | ||
| Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
|
||
| */ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| // Copyright (c) 2016 Intel Corporation. All rights reserved. | ||
| // See the bottom of this file for the license terms. | ||
|
|
||
| /* | ||
|
|
||
| Please note: | ||
| 1. This sketch makes use of ARC_SPI0. One of the two SPI connections from the ARC core. For the QUARK core SPI | ||
| connection, please refer to the SPI library. | ||
| 2. The ARC_SPI0 connections are not available in the Arduino 101 hardware platform. | ||
| 3. The expected Chip ID is 0x04 | ||
| 4. 0xFF denotes connection errors | ||
| 5. If you need to read the dummy reg value you can do an immediate memory read | ||
| */ | ||
| // This example uses a FRAM SPI chip | ||
| // Dataset is here : https://cdn-shop.adafruit.com/datasheets/MB85RS64V-DS501-00015-4v0-E.pdf | ||
| // Op codes: | ||
| /* Name Description Op-code | ||
| WREN Set Write Enable Latch 0000 0110B | ||
| WRDI Reset Write Enable Latch 0000 0100B | ||
| RDSR Read Status Register 0000 0101B | ||
| WRSR Write Status Register 0000 0001B | ||
| READ Read Memory Code 0000 0011B | ||
| WRITE Write Memory Code 0000 0010B | ||
| RDID Read Device ID 1001 1111B | ||
| */ | ||
| // The routing on the TT is as follows | ||
| /* TPB29 SPI0_SS_MOSI | ||
| TPB24 SPI0_SS_MISO | ||
| TPB23 SPI0_SS_SCK | ||
| TPB22 SPI0_SS_CS0 | ||
| TPB27 SPI0_SS_CS1 | ||
| TPB16 SPI0_SS_CS3 | ||
| */ | ||
|
|
||
| // include the SPI library: | ||
| #include <ARC_SPI0.h> | ||
| const uint8_t dummy_reg = 0x7F; | ||
| void setup() | ||
| { | ||
|
|
||
|
|
||
| Serial.begin(9600); // start serial for output | ||
| //while (!Serial) { }; | ||
|
|
||
| //Move pins to correct Test Point and call the correct macro | ||
| //SPI_SE_1 = CS0 -> TBP22 | ||
| //SPI_SE_2 = CS1 -> TPB27 | ||
| //SPI_SE_4 = CS3 -> TBP16 | ||
| // default now to CS 0 uncomment and move pins as needed | ||
| ARC_SPI0.begin(SPI_SE_1); // initialize SPI: | ||
| //ARC_SPI0.begin(SPI_SE_2); // initialize SPI: | ||
| //ARC_SPI0.begin(SPI_SE_4); // initialize SPI: | ||
|
|
||
| ARC_SPI0.transfer(dummy_reg); | ||
| } | ||
|
|
||
| void loop() | ||
| { | ||
| Serial.print("Transfer OpCode RDID. Return Value = 0x"); // print the character | ||
| uint8_t chip_id = ARC_SPI0.transfer(0x9F); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we be a bit more consistent with the data type being used for I2C data? one example uses |
||
| Serial.println(chip_id, HEX); // print the character | ||
| delay(1000); | ||
|
|
||
| //ARC_SPI0.transfer(dummy_reg); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 64 is commented out. Is it needed? if so, explain with another comment. If not, remove. |
||
| Serial.print("Transfer OpCode READ. Return Value = 0x"); // print the character | ||
| uint8_t mem_Read = ARC_SPI0.transfer(0x3); | ||
| Serial.println(mem_Read, HEX); // print the character | ||
| delay(1000); | ||
|
|
||
| Serial.print("Transfer OpCode RDSR. Return Value = 0x"); // print the character | ||
| uint8_t status_Register = ARC_SPI0.transfer(0x5); | ||
| Serial.println(status_Register, HEX); // print the character | ||
| delay(1000); | ||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
| /* | ||
| Copyright (c) 2016 Intel Corporation. All rights reserved. | ||
|
|
||
| This library is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU Lesser General Public | ||
| License as published by the Free Software Foundation; either | ||
| version 2.1 of the License, or (at your option) any later version. | ||
|
|
||
| This library 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 | ||
| Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public | ||
| License along with this library; if not, write to the Free Software | ||
| Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
|
||
| */ | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * ARC_I2C1.cpp is developed based upon the Wire.cpp module. | ||
| * | ||
| * TwoWire.h - TWI/I2C library for Linux Userspace | ||
| * Copyright (c) 2013 Parav https://github.com/meanbot. | ||
| * All rights reserved. | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library 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 | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| * | ||
| * Modifications to support Intel Arduino 101 | ||
| * Copyright (C) 2015 Intel Corporation | ||
| * | ||
| * Modifications made to support the two I2C connections of the ARC core | ||
| * Copyright (C) 2016 Intel Corporation | ||
| */ | ||
|
|
||
|
|
||
| #include "ARC_I2C1.h" | ||
|
|
||
| TwoWire ARC_I2C1 = TwoWire(I2C_SENSING_1); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * ARC_I2C1.h is developed based upon the TwoWire.h module. | ||
| * | ||
| * TwoWire.h - TWI/I2C library for Linux Userspace | ||
| * Copyright (c) 2013 Parav https://github.com/meanbot. | ||
| * All rights reserved. | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library 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 | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| * | ||
| * Modifications made to support the two I2C connections of the ARC core | ||
| * Copyright (C) 2016 Intel Corporation | ||
| */ | ||
|
|
||
| #ifndef _ARC_I2C1_H_ | ||
| #define _ARC_I2C1_H_ | ||
|
|
||
| #include "Wire.h" | ||
|
|
||
| extern TwoWire ARC_I2C1; | ||
|
|
||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one-letter variable names in sketches, not great for the user. How about something more descriptive, like
sendDataandreceiveData