The MBED firmware used on the Chipin sorter, developed over 12 weeks for a 3rd year university systems project. Chipin is a token sorter, it sorts tokens by colours and dispenses them to order through an online booking system and card reader. This program interfaces with an FPGA, PC and LCD screen to control the sorter. The sorter has an operation mode where it can process orders when a card is entered into the machine. There is also a maintenance mode where the device responds to maintenance instructions such as 'dispense all'. More information at http://www.ionsystems.uk/

Dependencies:   MCP23017 TCS3472_I2C WattBob_TextLCD mbed-rtos mbed

Committer:
IonSystems
Date:
Tue Nov 25 12:59:11 2014 +0000
Revision:
20:6de191ac7ff3
Parent:
12:814a8fdbb6f7
Child:
23:f9e7e64784be
Added wait functions for complete signals from FPGA.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IonSystems 6:e64796f1f384 1 #include "mbed.h"
IonSystems 12:814a8fdbb6f7 2 bool logEnable = true;
IonSystems 6:e64796f1f384 3 LocalFileSystem local("local");
IonSystems 6:e64796f1f384 4 void writeFile(int r, int g, int b){
IonSystems 12:814a8fdbb6f7 5
IonSystems 10:8c0696b99692 6 FILE* file = fopen("/local/datafile.txt","w"); // open file
IonSystems 12:814a8fdbb6f7 7 if(r >= 0){
IonSystems 10:8c0696b99692 8 fputc(r, file); // put char (data value) into file
IonSystems 12:814a8fdbb6f7 9 }else{
IonSystems 12:814a8fdbb6f7 10 fputc(0, file);
IonSystems 12:814a8fdbb6f7 11 }if(g >00){
IonSystems 10:8c0696b99692 12 fputc(g, file); // put char (data value) into file
IonSystems 12:814a8fdbb6f7 13 }else{
IonSystems 12:814a8fdbb6f7 14 fputc(0, file);
IonSystems 12:814a8fdbb6f7 15 }if(b >= 0){
IonSystems 10:8c0696b99692 16 fputc(b, file); // put char (data value) into file
IonSystems 12:814a8fdbb6f7 17 }else{
IonSystems 12:814a8fdbb6f7 18 fputc(0, file);
IonSystems 12:814a8fdbb6f7 19 }
IonSystems 10:8c0696b99692 20 fclose(file); // close file
IonSystems 12:814a8fdbb6f7 21
IonSystems 10:8c0696b99692 22 }
IonSystems 6:e64796f1f384 23
IonSystems 6:e64796f1f384 24 int readFile(int index){
IonSystems 10:8c0696b99692 25 FILE* file = fopen ("/local/datafile.txt","r"); // open file for reading
IonSystems 20:6de191ac7ff3 26 int read_var = 0;
IonSystems 6:e64796f1f384 27 for(int i = 0; i <= index; i++){
IonSystems 10:8c0696b99692 28 read_var = fgetc(file); // read data value
IonSystems 6:e64796f1f384 29 }
IonSystems 10:8c0696b99692 30 fclose(file); // close file
IonSystems 6:e64796f1f384 31 return read_var;
IonSystems 10:8c0696b99692 32 }
IonSystems 10:8c0696b99692 33
IonSystems 10:8c0696b99692 34 void log(char* text){
IonSystems 12:814a8fdbb6f7 35 /*if(logEnable){
IonSystems 10:8c0696b99692 36 FILE* file = fopen ("/local/log.txt", "a");
IonSystems 10:8c0696b99692 37 fputs(text, file);
IonSystems 10:8c0696b99692 38 fputs("\r\n", file);
IonSystems 10:8c0696b99692 39 fclose(file);
IonSystems 12:814a8fdbb6f7 40 }*/
IonSystems 10:8c0696b99692 41 }
IonSystems 10:8c0696b99692 42
IonSystems 10:8c0696b99692 43 void clearLog(){
IonSystems 10:8c0696b99692 44 FILE* file = fopen ("/local/log.txt", "w");
IonSystems 10:8c0696b99692 45 fclose(file);
IonSystems 10:8c0696b99692 46 }