Hi
I’m using following code for manage a shift register and works as spected when load code as dfu, but if i change to APP_TYPE = BOOT_SRAM then shift register doesn´t work. I don´t know if is because GPIO i´m using or other issue…
Any of you had an issue like this?
Thank you very much
Make file when i will boot from SRAM:
# Enable print float numbers
LDFLAGS = -u _printf_float
# Project Name
TARGET = testShiftRegister
# Sources
`Preformatted text`CPP_SOURCES = ${TARGET}.cpp \
OPT = -Os
# Boot options
APP_TYPE = BOOT_SRAM
# Library Locations
LIBDAISY_DIR = ../../libDaisy
DAISYSP_DIR = ../../DaisySP
# Core location, and generic makefile.
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
include $(SYSTEM_FILES_DIR)/Makefile
testShiftRegister.cpp file:
#include "daisy_seed.h"
#include "daisysp.h"
daisy::DaisySeed hw;
daisysp::Metro metro;
ShiftRegister595 sr;
float samplerate;
uint64_t counter = 0;
//*****************************************************************************
// Process audio
void AudioCallback(daisy::AudioHandle::InputBuffer in, daisy::AudioHandle::OutputBuffer out, size_t size);
//*****************************************************************************
// Reset shift register values
void ResetSr();
//*****************************************************************************
// Set shift register values
void SetSr(const uint8_t &channel, const bool &value);
//*****************************************************************************
// Main function
int main(void)
{
// Configure and Initialize the Daisy Seed
// These are separate to allow reconfiguration of any of the internal
// components before initialization.
hw.Configure();
hw.Init(true);
hw.SetAudioBlockSize(48);
//How many samples we'll output per second
samplerate = hw.AudioSampleRate();
// Initialize variables
metro.Init(1.0f, samplerate);
dsy_gpio_pin srPins[3] = {daisy::seed::D29, daisy::seed::D30, daisy::seed::D27};
sr.Init(srPins);
//Start calling the audio callback
hw.StartAudio(AudioCallback);
// Loop forever
while(true)
{
}
}
//*****************************************************************************
// Process audio
void AudioCallback(daisy::AudioHandle::InputBuffer in, daisy::AudioHandle::OutputBuffer out, size_t size)
{
float osc_out;
/** This loop will allow us to process the individual samples of audio */
for(size_t i = 0; i < size; i++)
{
if(metro.Process())
{
counter++;
if (counter > 7)
{
counter = 0;
}
}
SetSr(counter, true);
/** In this example both outputs will be the same */
out[0][i] = out[1][i] = osc_out;
}
}
//*****************************************************************************
// Reset shift register values
void ResetSr()
{
for (uint8_t i = 0; i < 8; i++)
{
sr.Set(i, true);
}
}
//*****************************************************************************
// Set shift register values
void SetSr(const uint8_t &channel, const bool &value)
{
ResetSr();
sr.Set(8 - channel - 1, !value);
sr.Write();
}