File tree Expand file tree Collapse file tree 4 files changed +55
-0
lines changed Expand file tree Collapse file tree 4 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: Apache-2.0
2+
3+ cmake_minimum_required (VERSION 3.20.0)
4+
5+ cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE} )
6+ set (DTC_OVERLAY_FILE ${ZephyrBase} /../modules/lib/Arduino-Zephyr-API/variants/${BOARD} /${BOARD} .overlay)
7+
8+ find_package (Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} )
9+ project (spi_controller)
10+
11+ target_sources (app PRIVATE src/app.cpp)
12+
13+ zephyr_compile_options(-Wno-unused-variable -Wno-comment )
Original file line number Diff line number Diff line change 1+ .. _spi_controller :
2+
3+ SPI Controller
4+ ###############
5+
6+ Overview
7+ ********
8+
9+ A simple sample that sends incrementing byte to SPI peripheral.
Original file line number Diff line number Diff line change 1+ CONFIG_CPLUSPLUS=y
2+ CONFIG_ARDUINO_API=y
3+ CONFIG_SPI=y
4+ CONFIG_LOG=y
5+ CONFIG_LOG_OUTPUT=y
6+ CONFIG_LOG_MODE_IMMEDIATE=y
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2024 Ayush Singh <ayush@beagleboard.org>
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ #include " SPI.h"
8+ #include < Arduino.h>
9+
10+ #define CHIPSELECT 3
11+
12+ static uint8_t data = 0 ;
13+
14+ void setup () {
15+ SPI.begin ();
16+ pinMode (CHIPSELECT, OUTPUT);
17+ digitalWrite (CHIPSELECT, HIGH);
18+ }
19+
20+ void loop () {
21+ SPI.beginTransaction (SPISettings (2000000 , MSBFIRST, SPI_MODE0));
22+ digitalWrite (CHIPSELECT, LOW);
23+ SPI.transfer (data++);
24+ digitalWrite (CHIPSELECT, HIGH);
25+ SPI.endTransaction ();
26+ delay (1000 );
27+ }
You can’t perform that action at this time.
0 commit comments