Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 8:5124be43c963, committed 2017-09-05
- Comitter:
- ThierryLeonard
- Date:
- Tue Sep 05 10:00:13 2017 +0000
- Parent:
- 6:909e7877d915
- Parent:
- 7:b1b4db3eedb4
- Child:
- 9:b9ac1d914762
- Commit message:
- merge
Changed in this revision
--- a/Accelerometre.h Tue Sep 05 05:51:17 2017 +0000
+++ b/Accelerometre.h Tue Sep 05 10:00:13 2017 +0000
@@ -1,3 +1,6 @@
+#ifndef ACCELEROMETRE_H
+#define ACCELEROMETRE_H
+
#include "mbed.h"
#include "MMA8452.h"
@@ -19,4 +22,8 @@
private:
double AngleCalculation(double ZValue);
- };
\ No newline at end of file
+ };
+
+
+
+ #endif
\ No newline at end of file
--- a/Afficheur.cpp Tue Sep 05 05:51:17 2017 +0000
+++ b/Afficheur.cpp Tue Sep 05 10:00:13 2017 +0000
@@ -1,18 +1,23 @@
#include "Afficheur.h"
-
+#ifdef USESPI
Afficheur::Afficheur():afficheur(p5,p6,p7),chipSelect(p8)
{
afficheur.format(8,0);
afficheur.frequency(50000);
chipSelect = 0;
}
-
- void Afficheur::write(char* characters,int length,int expo )
+#else
+ Afficheur::Afficheur():afficheur(),chipSelect(p8)
+ {
+ chipSelect = 1;
+ }
+#endif
+ void Afficheur::write(char* characters,int length )
{
-Serial pc(USBTX, USBRX);
+ Serial pc(USBTX, USBRX);
pc.printf("1");
static char buf[20];
pc.printf("2");
@@ -24,7 +29,7 @@
}
void Afficheur::write(char ch)
{
- static char buf[1];
+ char buf[1];
afficheur.write(&ch,1,buf,1);
}
void Afficheur::resetDisplay()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Afficheur.cpp.orig Tue Sep 05 10:00:13 2017 +0000
@@ -0,0 +1,46 @@
+
+
+#include "Afficheur.h"
+
+ Afficheur::Afficheur():afficheur(p5,p6,p7),chipSelect(p8)
+ {
+ afficheur.format(8,0);
+ afficheur.frequency(50000);
+ chipSelect = 0;
+ }
+
+ void Afficheur::write(char* characters,int length,int expo )
+ {
+
+Serial pc(USBTX, USBRX);
+ pc.printf("1");
+ static char buf[20];
+ pc.printf("2");
+ resetDisplay();
+ pc.printf("3");
+ afficheur.write(characters,length,buf,20);
+ pc.printf("4");
+ showDot(expo);
+ }
+ void Afficheur::write(char ch)
+ {
+ static char buf[1];
+ afficheur.write(&ch,1,buf,1);
+ }
+ void Afficheur::resetDisplay()
+ {
+ char buf[1];
+ afficheur.write("v",1,buf,1);
+ }
+ void Afficheur::showDot(int expo)
+ {
+ char command[2] = {'w',expo};
+ char buf[2];
+ afficheur.write(command,2,buf, 2);
+ }
+ void Afficheur::hideDot()
+ {
+ char command[2] = {'w',0};
+ char buf[2];
+ afficheur.write(command,2,buf, 2);
+ }
\ No newline at end of file
--- a/Afficheur.h Tue Sep 05 05:51:17 2017 +0000
+++ b/Afficheur.h Tue Sep 05 10:00:13 2017 +0000
@@ -1,9 +1,14 @@
+#ifndef AFFICHEUR_H
+#define AFFICHEUR_H
+
+
#include "mbed.h"
-#define USESPI
+#include "CommUART.h"
class Afficheur
{
+ typedef CommUART3 CommInterface;
public:
Afficheur();
@@ -14,11 +19,8 @@
void hideDot();
private:
- #ifdef USESPI
- SPI afficheur;
- #endif
- #ifdef USEUART
- UARTAfficheur afficheur;
- #endif
+ CommInterface afficheur;
DigitalOut chipSelect;
-};
\ No newline at end of file
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CommUART.h Tue Sep 05 10:00:13 2017 +0000
@@ -0,0 +1,63 @@
+#ifndef COMMUART_H
+#define COMMUART_H
+
+
+#include "mbed.h"
+#include "LPC17xx.h"
+
+class CommUART3
+{
+public:
+ CommUART3()
+ {
+ // Power
+ LPC_SC->PCONP |= (1 << 25) ;//0x400F C0C4 -> PCUART3
+ // Peripheral clock selection -> CCLK
+
+ // DLab enable divide latch
+ LPC_UART3->LCR |= (1 << 7);
+
+ // MSB of baud rate divisor
+ LPC_UART3->DLM = 0x2;
+ // MLB of baud rate divisor
+ LPC_UART3->DLL = 0x71;
+
+ // want 8-bit characters
+ LPC_UART3->LCR = 3;
+
+ // Enable FIFO
+ LPC_UART3->FCR = 1;
+
+ // PINSEL0 1:0 : mode p9 ->
+ LPC_PINCON->PINSEL0 &= ~3;
+ LPC_PINCON->PINSEL0 |= 2;
+ LPC_SC->PCLKSEL1 &= ~ (3 << 18 ) ; // clear the bits 18-19
+ LPC_SC->PCLKSEL1 |= 1 << 18 ;//0x400F C1AC -> PCLK_UART3 =01
+
+ }
+
+ void write(char ch)
+ {
+ LPC_UART3->TER = 0x80;
+ Serial pc(USBTX, USBRX);
+ pc.printf("%c", ch);
+ LPC_UART3->THR = ch;
+ }
+ void write(char* ch, int length, char* unused, int unused2)
+ {
+ Serial pc(USBTX, USBRX);
+ pc.printf("rip");
+ for(int i = 0 ; i < length ; i ++)
+ {
+ write(ch[i]);
+ }
+ }
+
+
+private:
+};
+
+
+
+
+#endif
\ No newline at end of file
--- a/MainEvr.cpp Tue Sep 05 05:51:17 2017 +0000
+++ b/MainEvr.cpp Tue Sep 05 10:00:13 2017 +0000
@@ -1,45 +1,45 @@
-#include "Accelerometre.h"
-#include "Afficheur.h"
-
-Serial pc(USBTX, USBRX);
-int main() {
-
-
-
- Afficheur afficheur;
- Accelerometre acc;
-
- double angle = 0;
-
- while(true){
-
- acc.readxyzAngle(&angle);
- pc.printf("angle is : %lf\r\n",angle);
-
-
-
- char c1[10];
- char c2[4];
-
- sprintf(c1 , "%4f" , angle);
- int virgule;
- int j =0;
- for(int i =0;i<4;i++){
- if(c1[j] == '.'){
- virgule = 1 <<j-1;
- i--;
- j++;
- continue;
- }
- c2[i] = c1[j];
- j++;
-
- }
-
- pc.printf("virg= %d",virgule);
- afficheur.write(c2,4, virgule);
-
- pc.printf("test");
- wait(0.45);
- }
-}
\ No newline at end of file
+//#include "Accelerometre.h"
+//#include "Afficheur.h"
+//
+//Serial pc(USBTX, USBRX);
+//int main() {
+//
+//
+//
+// Afficheur afficheur;
+// Accelerometre acc;
+//
+// double angle = 0;
+//
+// while(true){
+//
+// acc.readxyzAngle(&angle);
+// pc.printf("angle is : %lf\r\n",angle);
+//
+//
+//
+// char c1[10];
+// char c2[4];
+//
+// sprintf(c1 , "%4f" , angle);
+// int virgule;
+// int j =0;
+// for(int i =0;i<4;i++){
+// if(c1[j] == '.'){
+// virgule = 1 <<j-1;
+// i--;
+// j++;
+// continue;
+// }
+// c2[i] = c1[j];
+// j++;
+//
+// }
+//
+// pc.printf("virg= %d",virgule);
+// afficheur.write(c2,4, virgule);
+//
+// pc.printf("test");
+// wait(0.45);
+// }
+//}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MainEvr.cpp.orig Tue Sep 05 10:00:13 2017 +0000
@@ -0,0 +1,45 @@
+#include "Accelerometre.h"
+#include "Afficheur.h"
+
+Serial pc(USBTX, USBRX);
+int main() {
+
+
+
+ Afficheur afficheur;
+ Accelerometre acc;
+
+ double angle = 0;
+
+ while(true){
+
+ acc.readxyzAngle(&angle);
+ pc.printf("angle is : %lf\r\n",angle);
+
+
+
+ char c1[10];
+ char c2[4];
+
+ sprintf(c1 , "%4f" , angle);
+ int virgule;
+ int j =0;
+ for(int i =0;i<4;i++){
+ if(c1[j] == '.'){
+ virgule = 1 <<j-1;
+ i--;
+ j++;
+ continue;
+ }
+ c2[i] = c1[j];
+ j++;
+
+ }
+
+ pc.printf("virg= %d",virgule);
+ afficheur.write(c2,4, virgule);
+
+ pc.printf("test");
+ wait(0.45);
+ }
+}
\ No newline at end of file
--- a/maint.cpp Tue Sep 05 05:51:17 2017 +0000
+++ b/maint.cpp Tue Sep 05 10:00:13 2017 +0000
@@ -1,21 +1,19 @@
-//#include "mbed.h"
-//#include "Afficheur.h"
-//
-//#define USESPI
-//
-//
-//Serial pc(USBTX, USBRX); // tx, rx
-//
-//Afficheur afficheur;
-//
-//int main() {
-// while(1)
-// {
-// if(pc.readable())
-// {
-// afficheur.write(pc.getc());
-// }
-//
-// }
-//
-//}
+#include "mbed.h"
+#include "Afficheur.h"
+
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+Afficheur afficheur;
+
+int main() {
+ while(1)
+ {
+ if(pc.readable())
+ {
+ afficheur.write(pc.getc());
+ }
+
+ }
+
+}
