A test utility for mma8452

Dependencies:   MMA8452 mbed

Committer:
nherriot
Date:
Wed Oct 16 14:12:28 2013 +0000
Revision:
4:489573e65d47
A test utility for the mma8452 accelerometer.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nherriot 4:489573e65d47 1
nherriot 4:489573e65d47 2 #include "helperFunctions.h"
nherriot 4:489573e65d47 3
nherriot 4:489573e65d47 4 //Serial pc(USBTX, USBRX);
nherriot 4:489573e65d47 5
nherriot 4:489573e65d47 6 // This function will print a 7 bit char as a binary number on the screen
nherriot 4:489573e65d47 7 void printbincharpad(char c)
nherriot 4:489573e65d47 8 {
nherriot 4:489573e65d47 9 for (int i = 7; i >= 0; --i)
nherriot 4:489573e65d47 10 {
nherriot 4:489573e65d47 11 putchar( (c & (1 << i)) ? '1' : '0' );
nherriot 4:489573e65d47 12 if (i==4){putchar(':');}
nherriot 4:489573e65d47 13 }
nherriot 4:489573e65d47 14
nherriot 4:489573e65d47 15 }
nherriot 4:489573e65d47 16
nherriot 4:489573e65d47 17 // This function will take two characters and print formatted as a binary number on the screen
nherriot 4:489573e65d47 18 void print2bytebinchar(char *buffer)
nherriot 4:489573e65d47 19 {
nherriot 4:489573e65d47 20 printbincharpad(buffer[0]);
nherriot 4:489573e65d47 21 printf(" -- ");
nherriot 4:489573e65d47 22 printbincharpad(buffer[1]);
nherriot 4:489573e65d47 23 printf("\n");
nherriot 4:489573e65d47 24 }