-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Simple sample that sends bytes to SPI slave - Tested on beagleconnect freedom Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,13 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE}) | ||
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(spi_controller) | ||
|
||
target_sources(app PRIVATE src/app.cpp) | ||
|
||
zephyr_compile_options(-Wno-unused-variable -Wno-comment) |
This file contains 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,9 @@ | ||
.. _spi_controller: | ||
|
||
SPI Controller | ||
############### | ||
|
||
Overview | ||
******** | ||
|
||
A simple sample that sends incrementing byte to SPI peripheral. |
This file contains 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,6 @@ | ||
CONFIG_CPLUSPLUS=y | ||
CONFIG_ARDUINO_API=y | ||
CONFIG_SPI=y | ||
CONFIG_LOG=y | ||
CONFIG_LOG_OUTPUT=y | ||
CONFIG_LOG_MODE_IMMEDIATE=y |
This file contains 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,27 @@ | ||
/* | ||
* Copyright (c) 2024 Ayush Singh <ayush@beagleboard.org> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "SPI.h" | ||
#include <Arduino.h> | ||
|
||
#define CHIPSELECT 3 | ||
|
||
static uint8_t data = 0; | ||
|
||
void setup() { | ||
SPI.begin(); | ||
pinMode(CHIPSELECT, OUTPUT); | ||
digitalWrite(CHIPSELECT, HIGH); | ||
} | ||
|
||
void loop() { | ||
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0)); | ||
digitalWrite(CHIPSELECT, LOW); | ||
SPI.transfer(data++); | ||
digitalWrite(CHIPSELECT, HIGH); | ||
SPI.endTransaction(); | ||
delay(1000); | ||
} |