korginc / nts-1-customizations

Official repository for hardware customizations of the Nu:Tekt NTS-1 digital kit
BSD 3-Clause "New" or "Revised" License
147 stars 34 forks source link

nts1_iface.c: add aligned atrtribute to s_rx_event_decode_buf #9

Open boochow opened 4 years ago

boochow commented 4 years ago

Issue: The following sketch does not work. In the message handler rx_value(), val->value causes system crash. I suspected this is a memory alignment problem, and added __attribute__((aligned)) to s_rx_event_decode_buf in nts1_iface.c. Then it seems to work correctly.

#include <nts-1.h>

NTS1 nts1;

void rx_value(const nts1_rx_value_t *val) {
  Serial.print("req_id = ");
  Serial.println(val->req_id);
  Serial.print("value = ");
  Serial.println(val->value); // this line doesn't work!
}

void setup() {
  Serial.begin(9600);
  Serial.println("Start!");

  nts1.init(); 
  nts1.setValueEventHandler((nts1_value_event_handler) rx_value);
  nts1.reqOscCount();
}
void loop() {
  nts1.idle();
}