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.
Dependents: PulseWidthCapture_Program
Revision 0:538efd9574f7, committed 2014-12-10
- Comitter:
- Ellor1
- Date:
- Wed Dec 10 10:33:53 2014 +0000
- Child:
- 1:57aba608a20d
- Commit message:
- working Wait Function added;
Changed in this revision
| LCD_Wait.cpp | Show annotated file Show diff for this revision Revisions of this file |
| LCD_Wait.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_Wait.cpp Wed Dec 10 10:33:53 2014 +0000
@@ -0,0 +1,125 @@
+#include "mbed.h"
+#include "TextLCD_16x4.h"
+#include "LCD_Wait.h"
+
+//DigitalOut led(P0_9);
+//DigitalOut led2(P0_8);
+//DigitalOut led3(P0_7);
+//DigitalOut led4(P0_17);
+//DigitalOut led5(P0_1);
+
+LCD_Wait *LCD_Wait::instance;
+
+LCD_Wait::LCD_Wait(void)
+{
+
+ LPC_SYSCON->SYSAHBCLKCTRL |= CT16B1_CLK_ENABLE;
+
+ LPC_CT16B1->PR = 48000;
+
+ //LPC_CT16B1->MCR = CT16B1_MR0I | CT16B1_MR0R;
+
+ // LPC_CT16B1->IR = CT16B1_IR_MR0INT;
+
+
+
+ //instance = this;
+ //NVIC_SetVector(TIMER_16_1_IRQn, (uint32_t)&_Wait_ISR);
+
+}
+
+
+void LCD_Wait::Wait(float num_wait) {
+
+ // wait_n = num_wait;
+ //led = !led;
+
+ LPC_CT16B1->TC = 0;
+
+ // Start the timer
+ LPC_CT16B1->TCR = CT16B1_TCR_CEN; // enable
+
+ // blocking while loop that waits for the timer counter to exceed the set value
+ // If another interrupt fires during this while loop, this Wait function might take a little longer than expected
+ // while(LPC_CT16B1->TC < my_max_count_value);
+ while(LPC_CT16B1->TC < num_wait);
+
+ }
+
+ //Enable interrupt
+ // NVIC_EnableIRQ(TIMER_16_1_IRQn);
+
+ // Start the timer
+ // LPC_CT16B1->TCR = CT16B1_TCR_CEN; // enable
+
+ // LPC_CT16B1->MR0 = wait_n;
+
+ // }
+
+
+
+ /*
+void LCD_Wait::Wait(int num_wait) {
+
+ wait_n = num_wait;
+ led = !led;
+
+ //Enable interrupt
+ NVIC_EnableIRQ(TIMER_16_1_IRQn);
+
+ // Start the timer
+ LPC_CT16B1->TCR = CT16B1_TCR_CEN; // enable
+
+ //for (
+
+ //if (LPC_CT16B1->TC == wait_n) {
+
+ // NVIC_DisableIRQ(TIMER_16_1_IRQn);
+
+ //return;
+
+// }
+
+
+
+ // LPC_CT16B1->MR0 = wait_n;
+
+ }
+ */
+
+/*
+void LCD_Wait::Wait(int num_wait) {
+
+ wait_n = num_wait;
+ int x;
+ for (x = 0; x < wait_n; x++) {
+
+ }
+ x = 0;
+
+}
+*/
+
+/*
+void LCD_Wait::_Wait_ISR(void)
+{
+ instance->Wait_ISR();
+}
+
+void LCD_Wait::Wait_ISR(void) {
+
+ led2 = !led2;
+
+ // NVIC_DisableIRQ(TIMER_32_0_IRQn);
+ // NVIC_DisableIRQ(TIMER_32_1_IRQn);
+
+
+NVIC_DisableIRQ(TIMER_16_1_IRQn);
+
+LPC_CT16B1->IR = CT16B1_IR_MR0INT;
+
+ return;
+
+
+}
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_Wait.h Wed Dec 10 10:33:53 2014 +0000
@@ -0,0 +1,38 @@
+#ifndef LCD_H
+#define LCD_H
+
+#include "mbed.h"
+
+
+class LCD_Wait {
+public:
+
+LCD_Wait(void);
+void Wait(float num_wait);
+
+private:
+
+static void _Wait_ISR(void);
+void Wait_ISR(void);
+static LCD_Wait *instance;
+unsigned int wait_n;
+
+
+/* Private Macros ------------------------------------------------------------- */
+/* --------------------- BIT DEFINITIONS -------------------------------------- */
+
+
+#define CT16B1_IR_MR0INT ((uint32_t)(1<<0))
+
+#define CT16B1_CLK_ENABLE ((uint32_t)(1<<8))
+
+#define CT16B1_TCR_CEN 1UL
+
+#define CT16B1_MR0I ((uint32_t)(1<<0))
+
+#define CT16B1_MR0R ((uint32_t)(1<<1))
+
+
+};
+
+#endif
\ No newline at end of file