An RC5 decoder and preamp controller. Written on the LPC11U24, Ported to LPC1114 and now 100% stable (January 2016)
Dependents: AppleRemoteController_copy_Production_Version AppleRemoteController_Reference_Only
Diff: main.cpp
- Revision:
- 9:c9fb1f8e2ab8
- Parent:
- 4:d900d90588d0
- Child:
- 10:7a93d34a419a
diff -r 1f9fe4d67954 -r c9fb1f8e2ab8 main.cpp --- a/main.cpp Mon Nov 14 13:02:54 2022 +0000 +++ b/main.cpp Mon Nov 14 14:18:18 2022 +0000 @@ -43,7 +43,7 @@ #define VUP_timeout 45 // defines max number of R/C cycles before the vol ctrl mtr drive stops #define VDWN_timeout 45 // as above but for volume decrease // Needed to ensure the motor is not burnt out -#define DEBOUNCE 20 // this is the switch debounce time +#define DEBOUNCE 20000 // this is the switch debounce time // PHONO_ 1 // these are the input assignments written out // CD 2 // on select_out - see thePindef1114.h file for details @@ -107,7 +107,7 @@ if ((standbyflag == TRUE) && (key_press < VUP_timeout)) { FWD1 = HIGH; - wait(.1); //drive the motors for a short while + wait_us(100000); //drive the motors for a short while FWD1 = LOW; } @@ -117,7 +117,7 @@ key_press++; // button remained depressed, so increment counter } toggle1 = toggle; -// wait_ms(1); +// wait_us(100000); } /******************************* volume decrease **********************************/ @@ -126,7 +126,7 @@ if ((standbyflag == TRUE) && (key_press < VDWN_timeout)) { REV1 = HIGH; - wait(.1); //drive the motors for a short while + wait_us(100000); //drive the motors for a short while REV1 = LOW; } if (toggle1 != toggle) { @@ -135,7 +135,7 @@ key_press++; // button remained depressed, so increment counter } toggle1 = toggle; - wait_ms(1); + wait_us(1000); } /********************************** stdby_isr *************************************/ @@ -154,16 +154,16 @@ { __disable_irq(); stdby_int.fall(NULL); // on first power up cycle NO interrupts are accepted - wait_ms(DEBOUNCE); // a very simple debounce + wait_us(DEBOUNCE); // a very simple debounce do { // that waits for the depressed button to be released continue; //(1); } while (stdby != 1); if (standbyflag == TRUE) { // was ON so now turn it OFF stby_pa = LOW; - wait_ms(500); // make sure the power amp is OFF + wait_us(500000); // make sure the power amp is OFF // muteind = LOW; - wait_ms(1000); // make sure the power amp output goes OFF + wait_us(1000000); // make sure the power amp output goes OFF muteout = LOW; // now mute the preamp // turn off all interrupts except the standby and rc5int select_int.fall(NULL); @@ -173,9 +173,9 @@ // recloop_status = RECLOOP2; // reset the select so on subsequent power up it does //not skip recorder input select_save = select_drv; // save the status of select_drv - wait(.2); + wait_us(200000); select_drv = 0; // all input select relays are OFF - wait(3); + wait_us(3000000); standbyflag = FALSE; // muteind = HIGH; } @@ -190,16 +190,16 @@ // recloop_int.fall(&recloop_isr); // tone_pb.fall(tone_isr); // recloop_out = LOW; // make sure the recloop is OFF [its active HIGH] - wait_ms(100); + wait_us(100000); select_drv = select_save; // recall the input select setting and write to output - wait(2); // let things settle a bit + wait_us(2000000); // let things settle a bit muteout = HIGH; // enable output muteflag = TRUE; muteLED = HIGH; // turn the mute indicator OFF standbyflag = TRUE; stby_pa = HIGH; // now power up the amplifier } - wait_ms(500); // let things settle a bit + wait_us(500000); // let things settle a bit __enable_irq(); stdby_int.fall(&stdby_isr); // re-enable the standby interrupt @@ -263,7 +263,7 @@ muteLED = HIGH; } - wait_ms(100); + wait_us(100000); } @@ -443,7 +443,7 @@ { if (RCFLAG == FALSE) { // if used R/C skip completely - extra safety check - wait_ms(5); // debounce - very short for the rotary encoder + wait_us(5000); // debounce - very short for the rotary encoder select = 0; // flush select select = (select | sela) <<1; // read the two port lines associated with the select rotary encoder @@ -516,7 +516,7 @@ /************************************ main() ***************************************/ int main(void) { - Serial pc(USBTX, USBRX); +// Serial pc(USBTX, USBRX); __disable_irq(); // just to make sure we can set up correctly without problems stby_pa = LOW; // make sure the power amp is OFF via the trigger output muteout = LOW; //make sure the outputis muted from the get go @@ -533,7 +533,7 @@ stdby.mode(PullUp); // pin 26 // recloop_in.mode(PullUp); // pin 14 - wait(.2); + wait_us(200000); FLAG1 = FALSE; FLAG2 = FALSE; // FLAG5 = FALSE; // this is the recloop flag @@ -557,7 +557,7 @@ standbyflag = FALSE; select_save = 2; // CD always slected on initital power up select_rot = select_save; // CD will be selected when power is first turned on - wait(3); + wait_us(3000000); // muteind = LOW; __enable_irq();