clean :
find . -name \*.o -exec rm -f {} \;
find . -name .depend -exec rm -f {} \;
- rm -f *.map *.lst *.elf *.hex .depend $(COMMON)/common.a
+ rm -f *.map *.lst *.elf *.hex *.bin .depend $(COMMON)/common.a
#
#
//
int adcRead0_3 (void)
{
- AD0_CR = AD_CR_CLKS10 | AD_CR_PDN | ((11 - 1) << AD_CR_CLKDIVSHIFT) | AD_CR_SEL3;
- AD0_CR |= AD_CR_START_NOW;
+// AD0_CR = AD_CR_CLKS10 | AD_CR_PDN | ((11 - 1) << AD_CR_CLKDIVSHIFT) | AD_CR_SEL3;
+// AD0_CR |= AD_CR_START_NOW;
- while (!(AD0_DR3 & AD_DR_DONE))
- ;
+// while (!(AD0_DR3 & AD_DR_DONE))
+// ;
- return ((AD0_DR3 & AD_DR_RESULTMASK) >> AD_DR_RESULTSHIFT);
+// return ((AD0_DR3 & AD_DR_RESULTMASK) >> AD_DR_RESULTSHIFT);
+ return (0);
}
//
//
void adcInit (void)
{
- SCB_PCONP |= SCB_PCONP_PCAD0;
+// SCB_PCONP |= SCB_PCONP_PCAD0;
+ SCB_PCONP |= SCB_PCONP_PCAD1;
- PCB_PINSEL1 |= PCB_PINSEL1_P030_AD03;
+// PCB_PINSEL1 |= PCB_PINSEL1_P030_AD03;
- AD0_CR = AD_CR_CLKS10 | AD_CR_PDN | ((11 - 1) << AD_CR_CLKDIVSHIFT) | AD_CR_SEL3;
+ PCB_PINSEL0 |= PCB_PINSEL0_P012_AD13;
+ PCB_PINSEL0 |= PCB_PINSEL0_P013_AD14;
+ PCB_PINSEL1 |= PCB_PINSEL1_P021_AD16;
+
+}
+
+void adcStartXYZ (void)
+{
+// AD1_CR = AD_CR_CLKS10 | AD_CR_PDN | ((11 - 1) << AD_CR_CLKDIVSHIFT) | AD_CR_SEL3 | AD_CR_SEL4 | AD_CR_SEL6 | AD_CR_BURST;
+// AD1_CR = AD_CR_CLKS10 | AD_CR_PDN | ((11 - 1) << AD_CR_CLKDIVSHIFT) | AD_CR_SEL3 | AD_CR_BURST;
+ AD1_CR = AD_CR_CLKS10 | AD_CR_PDN | ((11 - 1) << AD_CR_CLKDIVSHIFT) | AD_CR_SEL6 | AD_CR_BURST;
+ AD1_CR |= AD_CR_START_NOW;
+
+// wait for conversion to complete
+// while (!(AD1_DR3 & AD_DR_DONE))
+// ;
+
+}
+
+//
+// Read and return X accelerometer value
+//
+int adcReadX (void)
+{
+// while (!(AD1_DR3 & AD_DR_DONE)) ;
+ return ((AD1_DR3 & AD_DR_RESULTMASK) >> AD_DR_RESULTSHIFT);
+}
+
+//
+// Read and return Y accelerometer value
+//
+int adcReadY (void)
+{
+// while (!(AD1_DR4 & AD_DR_DONE)) ;
+ return ((AD1_DR4 & AD_DR_RESULTMASK) >> AD_DR_RESULTSHIFT);
+}
+
+//
+// Read and return Z accelerometer value
+//
+int adcReadZ (void)
+{
+ while (!(AD1_DR6 & AD_DR_DONE)) ;
+ return ((AD1_DR6 & AD_DR_RESULTMASK) >> AD_DR_RESULTSHIFT);
}
int adcRead0_7 (void);
void adcInit (void);
+void adcStartXYZ (void);
+int adcReadX (void);
+int adcReadY (void);
+int adcReadZ (void);
+
#endif
#define AD0_DR6 (*(pREG32 (0xe0034028)))
#define AD0_DR7 (*(pREG32 (0xe003402c)))
-#define AD1_CR (*(pREG32 (0xe0064000)))
-#define AD1_GDR (*(pREG32 (0xe0064004)))
-#define AD1_STAT (*(pREG32 (0xe0064030)))
-#define AD1_GSR (*(pREG32 (0xe0034008)))
-#define AD1_INTEN (*(pREG32 (0xe006400c)))
-#define AD1_DR0 (*(pREG32 (0xe0064010)))
-#define AD1_DR1 (*(pREG32 (0xe0064014)))
-#define AD1_DR2 (*(pREG32 (0xe0064018)))
-#define AD1_DR3 (*(pREG32 (0xe006401c)))
-#define AD1_DR4 (*(pREG32 (0xe0064020)))
-#define AD1_DR5 (*(pREG32 (0xe0064024)))
-#define AD1_DR6 (*(pREG32 (0xe0064028)))
-#define AD1_DR7 (*(pREG32 (0xe006402c)))
+#define AD1_CR (*(pREG32 (0xe0060000)))
+#define AD1_GDR (*(pREG32 (0xe0060004)))
+#define AD1_STAT (*(pREG32 (0xe0060030)))
+#define AD1_GSR (*(pREG32 (0xe0030008)))
+#define AD1_INTEN (*(pREG32 (0xe006000c)))
+#define AD1_DR0 (*(pREG32 (0xe0060010)))
+#define AD1_DR1 (*(pREG32 (0xe0060014)))
+#define AD1_DR2 (*(pREG32 (0xe0060018)))
+#define AD1_DR3 (*(pREG32 (0xe006001c)))
+#define AD1_DR4 (*(pREG32 (0xe0060020)))
+#define AD1_DR5 (*(pREG32 (0xe0060024)))
+#define AD1_DR6 (*(pREG32 (0xe0060028)))
+#define AD1_DR7 (*(pREG32 (0xe006002c)))
#define AD_CR_SEL0 (0x00000001)
#define AD_CR_SEL1 (0x00000002)
int main (void)
{
cpuSetupHardware ();
-//#ifndef BDALE
uartInit (0, BAUD_UART0, 64);
uartInit (1, BAUD_UART1, 64);
-//#endif
#ifndef CFG_USB_MSC
usbserInit ();
#else
usbmassInit ();
#endif
-//#ifndef BDALE
rtcInit ();
adcInit ();
dacInit ();
-//#endif
i2cInit ();
-//#ifndef BDALE
eintsInit ();
fiqInit ();
iapInit ();
-//#endif
memset (taskHandles, 0, sizeof (taskHandles));
- xTaskCreate (vSensorsTask, (const signed portCHAR * const) "Sensors", 512, NULL, (configMAX_PRIORITIES - 2), &taskHandles [TASKHANDLE_SENSORS]);
-//#ifndef BDALE
+ xTaskCreate (vSensorsTask, (const signed portCHAR * const) "Sensors", 1024, NULL, (configMAX_PRIORITIES - 2), &taskHandles [TASKHANDLE_SENSORS]);
#ifndef CFG_CONSOLE_UART1
xTaskCreate (vGPSTask, (const signed portCHAR * const) "GPS", 768, NULL, (tskIDLE_PRIORITY + 1), &taskHandles [TASKHANDLE_GPS]);
#endif
-//#endif
xTaskCreate (vMonitorTask, (const signed portCHAR * const) "Monitor", 1024, NULL, (tskIDLE_PRIORITY + 1), &taskHandles [TASKHANDLE_MONITOR]);
-//#ifndef BDALE
xTaskCreate (vLEDFlashTask, (const signed portCHAR * const) "LEDx", configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1), &taskHandles [TASKHANDLE_LED]);
-//#endif
vTaskStartScheduler ();
return 0;
ft2232_vid_pid 0x15BA 0x0003
jtag_speed 3
#use combined on interfaces or targets that can't set TRST/SRST separately
-#reset_config trst_and_srst separate
-reset_config trst_and_srst srst_pulls_trst
+reset_config trst_and_srst separate
+#reset_config trst_and_srst srst_pulls_trst
#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 4 0x1 0xf 0xe
ft2232_vid_pid 0x15BA 0x0003
jtag_speed 3
#use combined on interfaces or targets that can't set TRST/SRST separately
-#reset_config trst_and_srst separate
-reset_config trst_and_srst srst_pulls_trst
+reset_config trst_and_srst separate
+#reset_config trst_and_srst srst_pulls_trst
#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 4 0x1 0xf 0xe
xTickCount = xTaskGetTickCount ();
+ adcStartXYZ();
+
for (;;)
{
vTaskDelayUntil (&xTickCount, 100 / portTICK_RATE_MS);
+ printf("tick\n");
+
//
// Adjust the DAC value so we output a slow sine wave
//
xSemaphoreGive (semaphore);
}
+
+ //
+ // get and display last X, Y, and Z accelerometer readings,
+ // the start another conversion
+ //
+ printf("%04x %04x %04x\n", adcReadX(), adcReadY(), adcReadZ());
+
}
}