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.
Diff: main.cpp
- Revision:
- 10:59582af3b94a
- Parent:
- 9:190ec4ad9ac7
- Child:
- 11:529d80511757
--- a/main.cpp Tue Jul 29 08:13:00 2014 +0000 +++ b/main.cpp Wed Jul 30 09:05:10 2014 +0000 @@ -22,8 +22,11 @@ //variables - char read_buffer[10]; + char read_buffer[11]; int content_buffer[63]; + unsigned int dataInteger0; + unsigned int dataInteger1; + unsigned int dataInteger2; //if you remove this line the program will fail //also make sure that you always send the status back to the host hostCommand = 0; @@ -31,29 +34,25 @@ pc.scanf(" %i, %i, %i, %i", &hostCommand, &hostData1, &hostData2, &hostData3); switch(hostCommand) { case 0: { - //wait_ms(1); + //read eeprom + sensor.RR(read_buffer,hostData1,hostData2); + printf("%i\n",(read_buffer[0]*65536)+(read_buffer[1]*256) + read_buffer[2]); break; } case 1: { - /* - ** Send 'read register' command to MLX90393. - * @param *receiveBuffer Pointer to receiveBuffer, will contain response of IC after command is sent. - * @param address The register to be read out. - * @param mode Communication mode (0=I2C, 1=SPI). - * @note The receiveBuffer will contain the status byte, followed by 2 bytes for the data at the specific register. - */ - //void RR(char *receiveBuffer, int address, int mode); + //read eeprom full for (int i = 0; i<63; i++) { sensor.RR(read_buffer,i,1); content_buffer[i] = (read_buffer[0]*65536)+(read_buffer[1]*256) + read_buffer[2]; - //printf("%i",content_buffer[i]); } for (int i = 0; i<63; i++) { - printf("%i\n",content_buffer[i]); + printf("%i\n",content_buffer[i]); } break; } case 2: { + //Write register + sensor.WR(read_buffer,hostData1,hostData2,hostData3); break; } case 3: { @@ -64,23 +63,27 @@ } case 5: { //exit - //printf("**gelukt** \n\r"); sensor.EX(read_buffer,1); printf("%i\n",read_buffer[0]); break; } case 6: { //single measurement - sensor.SM(read_buffer,hostData1,1); - printf("%i\n",read_buffer[0]); + sensor.SM(read_buffer,hostData1,hostData2); break; } case 7: { + //read measurement + sensor.RM(read_buffer,hostData1,hostData2); + dataInteger0 = (read_buffer[0]<<24)+ (read_buffer[1]<<16)+(read_buffer[2]<<8)+read_buffer[3]; + dataInteger1 = (read_buffer[4]<<24)+ (read_buffer[5]<<16)+(read_buffer[6]<<8)+read_buffer[7]; + dataInteger2 = (read_buffer[8]<<16)+ (read_buffer[9]<<8)+read_buffer[10]; + printf("%u,%u,%u\n",dataInteger0,dataInteger1,dataInteger2); break; } case 8: { //burst - sensor.SB(read_buffer,hostData1,1); + sensor.SB(read_buffer,hostData1,hostData2); printf("%i\n",read_buffer[0]); break; }