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 2:75c8a8b6b872, committed 2014-10-23
- Comitter:
- flatcat
- Date:
- Thu Oct 23 02:06:24 2014 +0000
- Parent:
- 1:37f04be9c0fa
- Commit message:
- Just need to get the analog values right
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 23 01:03:49 2014 +0000
+++ b/main.cpp Thu Oct 23 02:06:24 2014 +0000
@@ -1,5 +1,5 @@
#include "mbed.h"
-#include "cmsis_os.h"
+#include "rtos.h"
//configure I/O
InterruptIn masterClock_int(PB_14);
@@ -34,7 +34,7 @@
#define leadShieldedElements 13
#define headerElements 3
#define trailingDummyElements 14
-#define MV(x) ((0xFFF*x)/3300)
+//#define MV(x) ((0xFFF*x)/3300)
// MIST -- masterClock, icg, shiftGate, tigger
#define transition_1 4 // beginning 0100
#define transition_2 12 // clock_1 1100
@@ -49,7 +49,7 @@
#define transition_11 4 // t4 masterLow 0100 -- repeat from here
//define variables
-int pixelCount;
+long pixelCount;
int sensitivity = 10000;
double pixelData;
float firmwareVersion = 0.5;
@@ -87,22 +87,19 @@
void dataXfer_thread(void const *args){
while(1){
osSignalWait(0x2, osWaitForever);
-// if (trigger == 1){
- blueLED = 1;
-// for (int pixelNumber=0; pixelNumber<signalElements; pixelNumber++) {
-// raspi.printf("%i\t%4.12f\r\n", pixelNumber, 5 - ((pixelValue[pixelNumber - 1] * 5) / 4096.0));
-// osDelay(100);
-// }
- printf("Done.\r\n");
- blueLED = 0;
+// for (int pixelNumber=0; pixelNumber<signalElements; pixelNumber++) {
+// raspi.printf("%i\t%4.12f\r\n", pixelNumber, 5 - ((pixelValue[pixelNumber - 1] * 5) / 4096.0));
// }
- osDelay(1000);
+ osDelay(100);
+ printf("Done.\r\n");
+// osDelay(5000);
}
}
void imaging_thread(void const *args){
while(1){
osSignalWait(0x1, osWaitForever);// m icg sh trg
+ blueLED = 1;
tcd1304dg_clocks = transition_1; // | | | |
tcd1304dg_clocks = transition_2; // | | | |
tcd1304dg_clocks = transition_3; // | | | |
@@ -117,22 +114,22 @@
tcd1304dg_clocks = transition_9; // | | | |
}
for(int mcInc = 1; mcInc < pixelTotal; mcInc++ ){
-// pixelCount++;
tcd1304dg_clocks = transition_10; // | | | |
tcd1304dg_clocks = transition_11; // | | | |
-// pixelValue[pixelCount] = pixelIn.read_u16();
+// FLAG FOR PIXEL READ HERE
+// pixelCount++;
+// pixelValue[pixelCount] = pixelIn.read_u16();
+ raspi.printf("%i\t%4.12f\r\n", mcInc, (((pixelIn.read_u16()*5)/4096.0)));
tcd1304dg_clocks = transition_10; // | | | |
tcd1304dg_clocks = transition_11; // | | | |
}
-// osDelay(30);
tcd1304dg_clocks = 13;
-// osDelay(100);
+ blueLED = 0;
}
}
//define threads for imaging and data transfer
osThreadDef(imaging_thread, osPriorityRealtime, DEFAULT_STACK_SIZE);
-//osThreadDef(imaging_thread, osPriorityAboveNormal, DEFAULT_STACK_SIZE);
osThreadDef(dataXfer_thread, osPriorityNormal, DEFAULT_STACK_SIZE);
void init(){
@@ -144,6 +141,7 @@
illuminator = 0;
redLED = 0;
blueLED = 0;
+ pixelCount = 0;
}
int main(){
@@ -151,12 +149,12 @@
tcd1304dg_clocks = 0;
init();
raspi.baud(921600);
+ raspi.printf("Greetings.\r\n\r\n");
osThreadId img = osThreadCreate(osThread(imaging_thread), NULL);
osThreadId xfr = osThreadCreate(osThread(dataXfer_thread), NULL);
//command interpreter
while(true){
- redLED =!redLED;
char c = raspi.getc();
switch (c) {
case 'r':