Wire1 support for pins on SD socket (if not using SD card)
Hi Paul,
any chance you could map PTE0-5 including both UARTs alternates, I2C and SPI as, say, pins 58-63?
Wire1 support for pins on SD socket (if not using SD card)
More of question on the compiler than an issue. I am getting warnings during compile that variables are declared but not used. However, when I go into the code to check the variables are used but are used in "if-else" statements. Is there a way to fix this? I did try compiling with different options (not all of them) but got the same error.
Thanks
Mike
More of question on the compiler than an issue. I am getting warnings during compile that variables are declared but not used. However, when I go into the code to check the variables are used but are used in "if-else" statements. Is there a way to fix this? I did try compiling with different options (not all of them) but got the same error.
Thanks
Mike
void foo (void)
{
int a;
if (condition ()) {
a = 1;
// ..
} else {
// ...
}
// ...
if (a) { ... }
}
void foo (void)
{
int a = 0;
if (condition ()) {
a = 1;
// ...
} else {
// ...
}
// ...
if (a) {
// ...
}
}
void foo (void)
{
int a;
if (condition ()) {
a = 1;
// ...
} else {
a = 0;
// ...
}
// ...
if (a) {
// ...
}
}
void foo (void)
{
if (condition ()) {
int a = 1;
// ..
if (a) {
// ...
}
} else {
// ...
}
}
Per this post, I think you need to update the AudioControlSGTL5000::enable() method to select BCLK = 64 * Fs. I say "think" because I've only looked at the code, haven't actually tested it.
Serial.addStorageForRead(void *buffer, size_t length);
Serial.addStorageForWrite(void *buffer, size_t length);
@Paul - Any progress on the adding storage for Serial buffer design/code?
Is this something you wish to get into this release?
And if yes to any of this do you want some help on it?
If so, do you see it at least currently stay with C code for each UART or do you see it converting over to maybe something like we did to Wire and SPI objects, where one class, with hardware data structure passed in for each instance?
Or the other way of having additional begin methods where you can pass them in?
void uart0_status_isr(void) {
#ifdef HAS_KINETISK_UART0_FIFO
Serial1.status_isr_fifo();
#else
Serial1.status_isr();
#endif
}
void uart0_status_isr(void) {
#define UART_FIFO
Serial1.status_isr();
}
uint32_t current_baud = 38400;
void setup() {
while (!Serial && (millis() < 3000)) ;
Serial.begin(38400);
Serial.println("Test Serial ports");
Serial1.begin(current_baud);
Serial2.begin(current_baud);
Serial3.begin(current_baud);
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
Serial4.begin(current_baud);
Serial5.begin(current_baud);
Serial6.begin(current_baud);
#endif
}
void loop() {
Serial.printf("Output to all Serial ports at Baud %d\n", current_baud);
Serial1.println("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
delay(200); // give time for it to happen
Serial.println("Enter new baud or hit enter to continue using previous baud");
// See if the user
char szTemp[10];
uint32_t new_baud = 0;
int ch;
while ((ch = Serial.read()) != '\n') {
if ((ch >= '0') && (ch <= '9'))
new_baud = new_baud * 10 + ( ch - '0');
}
if (new_baud && (new_baud != current_baud)) {
current_baud = new_baud;
Serial1.end();
Serial2.end();
Serial3.end();
Serial1.begin(current_baud);
Serial2.begin(current_baud);
Serial3.begin(current_baud);
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
Serial4.end();
Serial5.end();
Serial6.end();
Serial4.begin(current_baud);
Serial5.begin(current_baud);
Serial6.begin(current_baud);
#endif
}
}
void serialEvent1() {
uint8_t buffer[80];
uint8_t cb = min (min(sizeof(buffer), Serial1.available()), Serial.availableForWrite());
Serial1.readBytes(buffer, cb);
Serial.write(buffer, cb);
}
void serialEvent2() {
uint8_t buffer[80];
uint8_t cb = min (min(sizeof(buffer), Serial2.available()), Serial2.availableForWrite());
Serial2.readBytes(buffer, cb);
Serial2.write(buffer, cb);
}
void serialEvent3() {
uint8_t buffer[80];
uint8_t cb = min (min(sizeof(buffer), Serial3.available()), Serial3.availableForWrite());
Serial3.readBytes(buffer, cb);
Serial3.write(buffer, cb);
}
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
void serialEvent4() {
uint8_t buffer[80];
uint8_t cb = min (min(sizeof(buffer), Serial4.available()), Serial4.availableForWrite());
Serial4.readBytes(buffer, cb);
Serial4.write(buffer, cb);
}
void serialEvent5() {
uint8_t buffer[80];
uint8_t cb = min (min(sizeof(buffer), Serial5.available()), Serial5.availableForWrite());
Serial5.readBytes(buffer, cb);
Serial5.write(buffer, cb);
}
void serialEvent6() {
uint8_t buffer[80];
uint8_t cb = min (min(sizeof(buffer), Serial6.available()), Serial6.availableForWrite());
Serial6.readBytes(buffer, cb);
Serial6.write(buffer, cb);
}
#endif
Serial1.addStorageForRead(rxBuffer1, sizeof(rxBuffer1));
Serial1.addStorageForWrite(txBuffer1, sizeof(txBuffer1));
Serial2.addStorageForRead(rxBuffer2, sizeof(rxBuffer2));
Serial2.addStorageForWrite(txBuffer2, sizeof(txBuffer2));
uint32_t current_baud = 38400;
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
// Optionally setup alternate pins
#define T356_ALTPINS
#endif
uint8_t rxBuffer1[100];
uint8_t txBuffer1[100];
uint8_t rxBuffer2[100];
uint8_t txBuffer2[100];
void setup() {
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
while (!Serial && (millis() < 3000)) ;
Serial.begin(38400);
Serial.println("Test Serial ports");
#ifdef T356_ALTPINS
Serial.println("Set Alt pins for T3.5/3.6");
Serial1.setRX(21);
Serial1.setTX(5);
#ifdef TEST_SDCARD_PINS
Serial2.setRX(59);
Serial2.setTX(58);
Serial4.setRX(63);
Serial4.setTX(62);
#endif
#endif
Serial1.addStorageForRead(rxBuffer1, sizeof(rxBuffer1));
Serial1.addStorageForWrite(txBuffer1, sizeof(txBuffer1));
Serial2.addStorageForRead(rxBuffer2, sizeof(rxBuffer2));
Serial2.addStorageForWrite(txBuffer2, sizeof(txBuffer2));
Serial.println("Test Serial ports");
Serial1.begin(current_baud);
Serial2.begin(current_baud);
Serial3.begin(current_baud);
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
Serial4.begin(current_baud);
Serial5.begin(current_baud);
Serial6.begin(current_baud);
#endif
}
void loop() {
Serial.printf("Output to all Serial ports at Baud %d\n", current_baud);
digitalWriteFast(2, HIGH);
Serial1.println("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
digitalWriteFast(2, LOW);
delay(200); // give time for it to happen
Serial.println("Enter new baud or hit enter to continue using previous baud");
uint32_t new_baud = 0;
int ch;
while ((ch = Serial.read()) != '\n') {
if ((ch >= '0') && (ch <= '9'))
new_baud = new_baud * 10 + ( ch - '0');
}
if (new_baud && (new_baud != current_baud)) {
current_baud = new_baud;
Serial1.end();
Serial2.end();
Serial3.end();
Serial1.begin(current_baud);
Serial2.begin(current_baud);
Serial3.begin(current_baud);
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
Serial4.end();
Serial5.end();
Serial6.end();
Serial4.begin(current_baud);
Serial5.begin(current_baud);
Serial6.begin(current_baud);
#endif
}
}
void serialEvent1() {
uint8_t buffer[80];
uint8_t cb = min (min((int)sizeof(buffer), Serial1.available()), Serial.availableForWrite());
Serial1.readBytes(buffer, cb);
Serial.write(buffer, cb);
}
void serialEvent2() {
uint8_t buffer[80];
uint8_t cb = min (min((int)sizeof(buffer), Serial2.available()), Serial2.availableForWrite());
Serial2.readBytes(buffer, cb);
Serial2.write(buffer, cb);
}
void serialEvent3() {
uint8_t buffer[80];
uint8_t cb = min (min((int)sizeof(buffer), Serial3.available()), Serial3.availableForWrite());
Serial3.readBytes(buffer, cb);
Serial3.write(buffer, cb);
}
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
void serialEvent4() {
uint8_t buffer[80];
uint8_t cb = min (min((int)sizeof(buffer), Serial4.available()), Serial4.availableForWrite());
Serial4.readBytes(buffer, cb);
Serial4.write(buffer, cb);
}
void serialEvent5() {
uint8_t buffer[80];
uint8_t cb = min (min((int)sizeof(buffer), Serial5.available()), Serial5.availableForWrite());
Serial5.readBytes(buffer, cb);
Serial5.write(buffer, cb);
}
void serialEvent6() {
uint8_t buffer[80];
uint8_t cb = min (min((int)sizeof(buffer), Serial6.available()), Serial6.availableForWrite());
Serial6.readBytes(buffer, cb);
Serial6.write(buffer, cb);
}
#endif
int HardwareSerial::peek(void)
{
uint32_t head, tail;
head = rx_buffer_head_;
tail = rx_buffer_tail_;
if (head == tail) return -1;
if (++tail >= rx_buffer_total_size_) tail = 0;
if (tail < rx_buffer_size_) {
return rx_buffer_[tail];
} else {
return rx_buffer_storage_[tail-rx_buffer_size_];
}
}
void usb_mtp_update(void)
{
serial_print("test\n");
// TODO: a lot of work here....
}
#ifdef T356_ALTPINS
Serial.println("Set Alt pins for T3.5/3.6");
Serial1.setRX(21);
Serial1.setTX(5);
#define XSERIAL Serial1
#define TXPIN 26 //5
#define RXPIN 27 //21
void setup() {
// put your setup code here, to run once:
while (!Serial && (millis() < 3000)) ;
Serial.begin(9600);
#ifdef TXPIN
XSERIAL.setTX(TXPIN);
#endif
#ifdef RXPIN
XSERIAL.setRX(RXPIN);
#endif
XSERIAL.begin(115200);
}
uint32_t last_output;
void loop() {
// put your main code here, to run repeatedly:
if ((millis() - last_output) >= 1000) {
XSERIAL.println("Test String");
last_output = millis();
}
int ch;
while ((ch = XSERIAL.read()) != -1)
Serial.write(ch);
}