This program send an AT command to the HC05 module and shows the response into a terminal.

Dependencies:   mbed-src MODSERIAL

Notebook page HERE

Files at this revision

API Documentation at this revision

Comitter:
edodm85
Date:
Thu May 31 19:52:52 2012 +0000
Child:
1:a11db105c379
Commit message:

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Thu May 31 19:52:52 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/code/MODSERIAL/#c11ea36f17f9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 31 19:52:52 2012 +0000
@@ -0,0 +1,58 @@
+/*
+ * Author: Edoardo De Marchi
+ * Date: 31-05-12
+ * Notes: AT command
+*/
+
+#include "mbed.h"
+#include "MODSERIAL.h"
+
+
+MODSERIAL pc(USBTX, USBRX);      // tx, rx
+MODSERIAL blue(p9,p10);          // HC05
+DigitalOut led1(LED1);
+DigitalOut led4(LED4);
+
+
+void commandAT(char *v){
+
+  int i=0;
+  
+  while(v[i] != NULL){ 
+    blue.putc(v[i]);
+    i++;
+  }
+  
+  blue.printf("\r\n");
+}
+
+
+// This function is called when a character goes into the RX buffer.
+void rxCallback(MODSERIAL_IRQ_INFO *q) {
+    led4 = !led4;
+    pc.putc(blue.getc());
+}
+
+
+int main(){
+  
+   blue.baud(38400);
+   pc.baud(115200);
+
+   char s[80];
+   
+   while(1){
+        pc.printf("Command: ");
+        pc.scanf("%s",s);
+      
+        wait_us(100);
+      
+        commandAT(s);
+        wait_us(100);
+        
+        pc.printf("Response: ");
+      
+        blue.attach(&rxCallback, MODSERIAL::RxIrq);
+        wait(1);
+    } 
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 31 19:52:52 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479