this is my code
#include"mbed.h"
#include"string.h"
#include"SPI.h"
#define MAX_INPUT_LENGTH 365
//Serial uart_7(PB_9, PB_8); // TX,RX Bluetooth Serial interface for machine-Mobile
Serial pc(USBTX, USBRX);
Serial uart_6(PG_14, PG_9);
//Serial bt(PG_14, PG_9);
Serial bt(PE_8, PE_7);
Serial uart_4(PC_10, PC_11);
Serial uart_5(PB_9, PB_8); // tx, rx (serial Communication Tera Term)
SPI Master_To_Slave(PB_5,PA_6,PA_5); // mosi, miso, sclk
DigitalOut Slave1_Selection(PA_4); //master NUCLEO-F746ZG slave selection pin
DigitalOut Master_Led(PG_3);
char Send_String[20] = "KALAIVANAN#";
char Received_String[20]="\0";
const PinMap PinMap_UART_TX[] = {
{PB_9, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)},
{PC_10, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
{NC, NC, 0}
};
const PinMap PinMap_UART_RX[] = {
{PB_8, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)},
{PC_11, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
{NC, NC, 0}
};
int main() {
pc.baud(115200);
//uart_7.baud(9600);
// uart_6.baud(115200);
bt.baud(9600);
uart_4.baud(115200);
uart_5.baud(115200);
int i = 0;
int j = 0;
int ch;
char send_data[50] = {'\0'};
char k = 0;
Slave1_Selection = 1; // De_Select the 1st Slave
Master_To_Slave.format(8, 3); // Setup: 8bit mode 3
Master_To_Slave.frequency(1000000); // Starting Frequency 1 MHZ
while (1) {
pc.printf("\n Select The case :\n");
pc.scanf("%d", &ch);
switch (ch) {
/* case 1: {
pc.printf("nucleo to nucleo SPI Communication\n");
while (Send_String[i] != '#') // Send the String Upto Null
{
Slave1_Selection = 0; // Select the 1st Slave (Activate)
pc.printf(" \n Send_String = %c ", Send_String[i]);
Master_To_Slave.write(Send_String[i]);
Master_Led = !Master_Led; // LEd Blinking While Data Transfer
Slave1_Selection = 1; // De_Select the 1st Slave
wait_ms(200); // Wait for readability only(Ready to wait for Next Data)
i++;
}
} break;
case 2: {
pc.printf("nucleo to nucleo SPI Communication\n");
while (Send_String[i] != '#') // Send the String Upto Null
{
Slave1_Selection = 0; // Select the 1st Slave (Activate)
pc.printf(" \n Send_String = %c ", Send_String[i]);
Master_To_Slave.write(Send_String[i]);
Master_Led = !Master_Led; // LEd Blinking While Data Transfer
Slave1_Selection = 1; // De_Select the 1st Slave
wait_ms(200); // Wait for readability only(Ready to wait for Next Data)
i++;
}
if (Send_String[i] == '#') {
if (Master_To_Slave.receive())
; // start Reading from Master
{
Slave1_Selection = 0;
Received_String[j] = Master_To_Slave.read();
pc.printf("\n Slave1 Received String %c",
Received_String[j]); // print the Receiving Char
Master_Led = !Master_Led; // LEd Blinking While Data Transfer
Slave1_Selection = 1;
wait_ms(200); // waiting
j++;
}
}
} break;
*/
case 3: {
char buff[MAX_INPUT_LENGTH];
int code[MAX_INPUT_LENGTH];
int n = 0;
char keyIn;
memset(buff, 0, sizeof(buff));
while (true) {
pc.printf("\n waiting for bluetooth data");
bt.printf("Waiting for String #");
while (n <= MAX_INPUT_LENGTH - 1) {
if (bt.readable()) {
keyIn = bt.getc();
if (keyIn == '\n' || keyIn == '\r') {
break;
}
buff[n] = keyIn;
code[n] = keyIn - '0';
n++;
} else {
wait_us(100);
}
}
pc.printf("\nReceived: %s\n", buff);
pc.printf("\n Processed data: ");
for (int y = 0; y < n; y++) {
pc.printf("%d", code[y]);
bt.printf("%d", code[y]);
}
wait_ms(100);
bt.printf("#");
}
} break;
case 4: {
while (true) {
memset(send_data, 0, sizeof(send_data));
printf("\n\rEnter a message to send to Slave: ");
scanf("%s", send_data);
uart_4.putc('R');
while (uart_4.getc() != 'A');
printf("\n\rSlave ready. Sending message...\n");
for (int i = 0; send_data[i] != '\0'; i++) {
uart_4.putc(send_data[i]);
while (uart_4.getc() != 'A');
}
}
} break;
case 5: {
while (true) {
memset(send_data, 0, sizeof(send_data));
printf("\n\rEnter a message to send to Slave: ");
scanf("%s", send_data);
uart_5.putc('R');
while (uart_5.getc() != 'A');
printf("\n\rSlave ready. Sending message...\n");
for (int i = 0; send_data[i] != '\0'; i++) {
uart_5.putc(send_data[i]);
while (uart_5.getc() != 'A');
}
}
break;
case 6: {
while (true) {
printf("\n\rUART 6 DEMONSTRATION....");
char received_data[50] = {0};
memset(send_data, 0, sizeof(send_data));
printf("\n\rEnter a message to send to Slave: ");
scanf("%s", send_data);
int i = 0;
for(i = 0; send_data[i] != '\0'; i++)
{
// uart_6.putc(send_data[i]);
// received_data[i] = uart_6.getc();
}
printf("\n\rReceived message from Master %s",received_data);
}
}
break;
case 7: {
while (true) {
printf("\n\rUART 7 DEMONSTRATION....");
char received_data[50] = {0};
memset(send_data, 0, sizeof(send_data));
printf("\n\rEnter a message to send to Slave: ");
scanf("%s", send_data);
int i = 0;
for(i = 0; send_data[i] != '\0'; i++)
{
//uart_7.putc(send_data[i]);
//received_data[i] = uart_7.getc();
}
printf("\n\rReceived message from Master %s",received_data);
}
}break;
}
}
}
}
these are shoeing error…
Build started
Using toolchain ARM_STD profile {'ENV': {'ARMLMD_LICENSE_FILE': '8224@10.100.182.21:8224@10.100.106.178'}, 'PATHS': {'ARMC6_PATH': '/opt/ARMCompiler6.15.13/bin/', 'ARM_PATH': '/opt/armcc5_06_u6/'}, 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'], 'cxx': ['--cpp', '--no_rtti'], 'COMPILE_C_AS_CPP': False, 'NEW_SCAN_RESOURCES': True}
scan /tmp/chroots/ch-739e1ce9-9f68-44eb-88a4-c53dd11fbf04/src
scan /tmp/chroots/ch-739e1ce9-9f68-44eb-88a4-c53dd11fbf04/extras/mbed-os.lib
Configuration error: 'static_memory_defines' is not defined.
#20: identifier "PinMap" is undefined
#20: identifier "PinMap" is undefined
#111-D: statement is unreachable
#111-D: statement is unreachable
#111-D: statement is unreachable
#111-D: statement is unreachable
#111-D: statement is unreachable
#177-D: variable "i" was declared but never referenced
#177-D: variable "j" was declared but never referenced
#177-D: variable "k" was declared but never referenced
"/src/main.cpp", line 20: Error: #20: identifier "PinMap" is undefined
const PinMap PinMap_UART_TX[] = {
^
"/src/main.cpp", line 26: Error: #20: identifier "PinMap" is undefined
const PinMap PinMap_UART_RX[] = {
^
"/src/main.cpp", line 128: Warning: #111-D: statement is unreachable
} break;
^
"/src/main.cpp", line 144: Warning: #111-D: statement is unreachable
} break;
^
"/src/main.cpp", line 160: Warning: #111-D: statement is unreachable
break;
^
"/src/main.cpp", line 180: Warning: #111-D: statement is unreachable
break;
^
"/src/main.cpp", line 198: Warning: #111-D: statement is unreachable
}break;
^
"/src/main.cpp", line 41: Warning: #177-D: variable "i" was declared but never referenced
int i = 0;
^
"/src/main.cpp", line 42: Warning: #177-D: variable "j" was declared but never referenced
int j = 0;
^
"/src/main.cpp", line 45: Warning: #177-D: variable "k" was declared but never referenced
char k = 0;
^
/src/main.cpp: 8 warnings, 2 errors
Internal error.
Build failed
Build failed
compile main.cpp