A test utility for mma8452

Dependencies:   MMA8452 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers helperFunctions.cpp Source File

helperFunctions.cpp

00001 
00002 #include "helperFunctions.h"
00003 
00004 //Serial pc(USBTX, USBRX);
00005 
00006 // This function will print a 7 bit char as a binary number on the screen
00007 void printbincharpad(char c)
00008 {
00009     for (int i = 7; i >= 0; --i)
00010     {
00011         putchar( (c & (1 << i)) ? '1' : '0' );
00012         if (i==4){putchar(':');}
00013     }
00014     
00015 }
00016 
00017 // This function will take two characters and print formatted as a binary number on the screen
00018 void print2bytebinchar(char *buffer)
00019 {
00020     printbincharpad(buffer[0]);
00021     printf(" -- ");
00022     printbincharpad(buffer[1]);
00023     printf("\n");
00024 }