Looking up interrupts from MaxBotix Maxsonar MB73x0 ultrasonic gauge and writing data and timestamp to SD flash card. I'm using MB7380 with STM32F103C8T6 minimal board from Ali (it's perfect MCU board for small projects!).
Dependencies: SDFileSystem mbed
main.cpp
- Committer:
- shtirlitz
- Date:
- 2016-03-14
- Revision:
- 0:2ce0698a332d
- Child:
- 1:5c9bde92518d
File content as of revision 0:2ce0698a332d:
#include "mbed.h" Serial pc(PA_2, PA_3); // This is USB tx, rx Serial sensor_uart(PA_9, PA_10); // This is USART2 tx, rx DigitalOut myled(PB_5); // This is USER LED DigitalOut myled2(PA_7); // This is USER LED DigitalIn BlueButton(PB_9); // This is Blue-Button #define Pressed 0 #define NotPressed 1 int USBByte='\0'; int GaugeByte='\0'; int n=0; int readgauge = 0; Timer t; char str[5]; long millis = 0; void PC_INT() // USART2 used for Debug { // Note: you need to actually read from the serial to clear the RX interrupt pc.putc(pc.getc()); myled = (myled)?(0):(1); } void SENSOR_USART_INT() // SENSOR_USART { // Note: you need to actually read from the serial to clear the RX interrupt //myled = 1; //Serial3.scanf(str); //sensor_uart.scanf("%5s", str); //str = strcat (" PISKA ", str); //sprintf(millis, "%d", t.read_ms()); //int k = 0; //for (k = 0; k < 10; k++){;} //str = strcat (millis, str); //pc.printf(str); //pc.printf(millis); if (sensor_uart.getc() == 'R') { myled = (myled)?(0):(1); pc.printf("timestamp: %d; gauge value: %s\r\n", t.read_ms(), sensor_uart.gets(str, 5)); } } int main() { myled = 0; // SetUp the baud rate pc.baud(9600); sensor_uart.baud(9600); sensor_uart.attach(&SENSOR_USART_INT); pc.attach(&PC_INT); t.start(); pc.printf("\n\r\n\r|||||START MAIN|||||\n\r"); while(1) { // Test the Blue Button while(BlueButton == Pressed) { myled2 = BlueButton; pc.printf("Please release the BLUE Button\n\r"); } } }