forked from electro-smith/libDaisy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SPI - odd sequence at end of data: electro-smith#553
- Loading branch information
Showing
3 changed files
with
96 additions
and
1 deletion.
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,14 @@ | ||
# Project Name | ||
TARGET = OledSPI | ||
|
||
# Sources | ||
CPP_SOURCES = OledSPI.cpp | ||
|
||
# Library Locations | ||
LIBDAISY_DIR = ../../ | ||
|
||
#APP_TYPE = BOOT_SRAM | ||
|
||
# Core location, and generic Makefile. | ||
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core | ||
include $(SYSTEM_FILES_DIR)/Makefile |
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,81 @@ | ||
/** | ||
* @author eh2k | ||
* @brief | ||
* @date 2023-01-08 | ||
* | ||
* OLED using hardware spi | ||
* Shows how to setup an OLED display on the Daisy Patch SM using hardware spi. | ||
*/ | ||
|
||
#include "daisy_patch_sm.h" | ||
#include "dev/oled_ssd130x.h" | ||
|
||
using namespace daisy; | ||
using namespace patch_sm; | ||
|
||
DaisyPatchSM hw; | ||
|
||
using namespace daisy; | ||
using namespace daisy::patch_sm; | ||
|
||
using MyDisplay = OledDisplay<SSD130x4WireSpi128x64Driver>; | ||
MyDisplay display; | ||
|
||
void AudioCallback(AudioHandle::InputBuffer in, | ||
AudioHandle::OutputBuffer out, | ||
size_t size) | ||
{ | ||
// | ||
} | ||
|
||
int main(void) | ||
{ | ||
// Initialize the hardware | ||
hw.Init(); | ||
hw.StartAudio(AudioCallback); | ||
|
||
MyDisplay::Config display_config; | ||
|
||
SpiHandle::Config& spi_conf = display_config.driver_config.transport_config.spi_config; | ||
|
||
spi_conf.mode = SpiHandle::Config::Mode::MASTER; // we're in charge | ||
spi_conf.periph = SpiHandle::Config::Peripheral::SPI_2; // Use the SPI_2 Peripheral | ||
spi_conf.direction = SpiHandle::Config::Direction::ONE_LINE; // TWO_LINES_TX_ONLY; | ||
|
||
spi_conf.datasize = 8; | ||
spi_conf.clock_polarity = SpiHandle::Config::ClockPolarity::LOW; | ||
spi_conf.clock_phase = SpiHandle::Config::ClockPhase::ONE_EDGE; | ||
// spi_conf.nss = SpiHandle::Config::NSS::HARD_OUTPUT; | ||
spi_conf.baud_prescaler = SpiHandle::Config::BaudPrescaler::PS_128; | ||
|
||
// Pins to use. These must be available on the selected peripheral | ||
spi_conf.pin_config.sclk = DaisyPatchSM::D10; // Use pin D10 as SCLK | ||
spi_conf.pin_config.miso = Pin(); // We won't need this | ||
spi_conf.pin_config.mosi = DaisyPatchSM::D9; // Use D9 as MOSI | ||
spi_conf.pin_config.nss = Pin(); // DaisyPatchSM::D1; // use D1 as NSS | ||
|
||
// data will flow from master to slave over just the MOSI line | ||
|
||
// The master will output on the NSS line | ||
spi_conf.nss = SpiHandle::Config::NSS::SOFT; | ||
|
||
display_config.driver_config.transport_config.pin_config.dc | ||
= DaisyPatchSM::D2; | ||
display_config.driver_config.transport_config.pin_config.reset | ||
= DaisyPatchSM::D3; | ||
display.Init(display_config); | ||
|
||
char tmp[64]; | ||
|
||
// loop forever | ||
while(1) | ||
{ | ||
ScopedIrqBlocker _; | ||
|
||
display.Fill(false); | ||
display.SetCursor(0, 0); | ||
sprintf(tmp, "%d", System::GetUs()); | ||
display.WriteString(tmp, Font_6x8, true); | ||
display.Update(); | ||
} | ||
} |
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