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: AppleRemoteController_copy_Production_Version AppleRemoteController_Reference_Only
Revision 3:f0cd7c22ca94, committed 2022-07-26
- Comitter:
- andrewcrussell
- Date:
- Tue Jul 26 16:24:40 2022 +0000
- Parent:
- 2:674e2dd56e7d
- Child:
- 4:d900d90588d0
- Child:
- 5:9525755f7457
- Commit message:
- Apple Remote
Changed in this revision
--- a/Pindef1114.h Fri Nov 20 14:36:14 2015 +0000
+++ b/Pindef1114.h Tue Jul 26 16:24:40 2022 +0000
@@ -1,40 +1,39 @@
/************************************ Pinfef1114.h *******************************/
-
+/****************** for the RC5 preamplifier copntroller program ****************/
DigitalOut FWD1(dp1); // these are the motor 'H' bridge drive signals
DigitalOut REV1(dp2); // when the volume controll motor is not being driven
// they are all OFF
-DigitalOut muteout(dp11); // drives the mute relay via a mosfet or transistor
-DigitalOut muteind(dp18); // drives the mute indicator on the front panel
-InterruptIn mute_int(dp13); // mute p/button interrupt
-DigitalIn mute(dp13); // mute input from associated pushbutton
+DigitalOut muteout(dp13); // drives the mute relay via a mosfet or transistor
+DigitalOut muteind(dp18);
+InterruptIn mute_int(dp11); // mute p/button interrupt
+DigitalIn mute(dp11); // mute input from associated pushbutton
-DigitalIn TXD(dp16);
-
-InterruptIn rc5int(dp15); // this is the R/C interrupt triggered by the IRx data out
-DigitalIn rc5dat(dp15); // data is read in from here - its coming from the IRx data out
+DigitalOut stby_pa(dp25); // power amplifier standby control which follows the premap
+ // but with suitable delays
+
+InterruptIn rc5int(dp17); // this is the R/C interrupt triggered by the IRx data out
+DigitalIn rc5dat(dp17); // data is read in from here - its coming from the IRx data out
InterruptIn select_int(dp28); // select rotary encoder interrupt - we use the 'A' O/P to generate the interrupt
DigitalIn sela(dp28); // select input rotary enc input A
DigitalIn selb(dp27); // select input rotary enc input B
-
-
DigitalIn stdby(dp26); // standby function p/button input
InterruptIn stdby_int(dp26); // standby p/button interrupt in
+//InterruptIn tone_pb(dp15);
+//DigitalIn tone(dp15);
+//DigitalOut tone(dp25); // can only be turned on and off at this stage by the r/control
InterruptIn recloop_int(dp14); //record loop interrupt
DigitalIn recloop_in(dp14); // record loop p/button input
-DigitalOut recloop_out(dp5); // drives record loop relay via mosfet or transistor NOTE: WAS dp24
-
-
+DigitalOut recloop_out(dp16); // drives record loop LED
+DigitalOut recloop_rly(dp10);
-//DigitalOut power_ind(dp25); // this pin drives the standby controller - LOW = OFF; use regulators with standby inpu
-
-BusOut select_drv(dp17,dp4, dp25, dp6, dp9, dp10); //these are the select relay drivers
+BusOut select_drv(dp24,dp4, dp5, dp6, dp9, dp10); //these are the select relay drivers
// note that we do not explicitly define the input select output ports because we just move the active
// output port bit around in a continuos loop with each depress of the select button. Drive the associated
// input relays via a mosfet or transistor
--- a/main.cpp Fri Nov 20 14:36:14 2015 +0000
+++ b/main.cpp Tue Jul 26 16:24:40 2022 +0000
@@ -1,5 +1,5 @@
/****************************** RC5 Decoder and Preamp Controller V1.0 *************************/
-/* AndrewR written in 2015 */
+/* Andrew C. Russell (c) 2015 */
/* This RC5 decoder works by reading in the RC5 stream from one of the serial port lines */
/* and saving the incoming stream into an array called stream, after which it is decoded and */
/* the command executed. A Marantz RC-68PM IR R/C was used to develop this program - it */
@@ -13,38 +13,46 @@
/* 4. Record loop via push button actuation */
/* 5. Power ON output to drive the /standby input of a system power supply */
/* Facilities 1,2,3 and 5 are supported by an RC5 compliant remote control for preamplifiers */
-/* The program can be used with either the LPC11U24 or the LPC1114 - just use the appropriate */
-/* Pindfefxxxx.h file */
+/* The controller pin definitions are set in Pindef1114.h file. */
+
+
+// UPDATE 26 July 2018: tone functionality removed. The associated pin (dp25) has been sequestrated
+// for the standby output to drive a power amplifier. Pin 8 on J2 (Controller board)
#include "mbed.h"
-#include "rc5codes.h" // Philips RC5 code definitions
+#include "rc5codes.h" // RC code definitions - in this case for Apple TV Remote
#include "Pindef1114.h" // all microcontroller I/O pin assignments defined here
#define TRUE 1
#define FALSE 0
#define HIGH 1
#define LOW 0
-#define rc5_bitcount 14 // number of RC5 bits
-#define tick 444 // quarter bit time in us
-#define tock 1778 // one bit time in us
-#define VUP_timeout 10 // defines max number of R/C cycles before the vol ctrl mtr drive stops
-#define VDWN_timeout 10 // as above but for volume decrease. Needed to ensure the motor is not burnt out
+#define tick 280 // quarter bit time in us
+#define tock 1120 // one bit time in us
+#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 PHONO_IN 1 // these are the input assignments - not used in V1.0 of the
-//#define CD_IN 2 // controller since the input select is just stepped
-//#define TUN_IN 4 // through from PHONO_IN to REC_IN and back again
-//#define AUX1_IN 8
-//#define MSERV_IN 16
-//define REC_IN 32
+// PHONO_ 1 // these are the input assignments written out
+// CD 2 // on select_out - see thePindef1114.h file for details
+// TUN 4
+// MSERV 8
+// AUX 16
+// RECORDER 32
int startbit;
-int toggle; // this is the 3rd bit position in the input stream and checks for
- // subsequent button depresses from the r/control
+int toggle; // this is the 3rd bit position in the input stream and checks for
+// subsequent button depresses from the r/control
int toggle1; // temorary storage in the volume UP and volume DOWN functions
int toggle2; // temprary storage of the PB in the mute function
+int toggle3; // temp storage for the r/control tone in-out function
int standby;
-int address;
-int command;
+int command = 0;
+int vendor_id = 0;
+int pair_command = 0;
+int address = 0;
+int stop_bit = 0;
int FLAG1; // this is used in the remote control input processing
int FLAG2; // this is used in the select input processing
@@ -52,25 +60,34 @@
int FLAG4; // this is for the standby pushbutton
int FLAG5; // this is the recloop flag
int RCFLAG = FALSE; // used to determine if the select command came via R/C
+int REPEATFLAG; // repaet command flag used for volume control
+int FLAGVOLUP;
+int FLAGVOLDWN;
+int FLAG7 = FALSE; // thyis flag is set to TRUE if recloop is active
int standbyflag; // used to save the standby condition
-
+int RECLOOP1 = 16; // this is the bus address 1 before the Recorder
+int RECLOOP2 = 32; // this is the bus address for the Recorder input
+// and is used in the recloop service routine
+int muteflag = FALSE; // use to control mute and mute indicatoe independently
+int recloop_status = 32; // this is the initial value. This variable is used
+// in the select_out routine to indicate when the
+// input select should wrap around dependent upon
+// whether the record loop has been activated.
int relay;
int key_press = 1; // keeps track of key presses
-int toggle_press = 1; //stores value of toggle for key_press routine
// delcarations below are all for the input select proceses
int select = 0;
-int select_save = 1; // we save the status of select drive here. Initial value is 1
-int select_rot = 1; // rotary encoder pulse counter
-
-//int loop_counter = 0; // debug loop counter
+int select_save = 2; // we save the status of select drive here. Initial setting is for CD
+int select_rot; // rotary encoder pulse counter
// declare function prototypes here
-void select_out (void);
-void rc5isr(void);
+void select_out (void); // writes selected input out to the select_drv bus
+void select_isr(void);
+void rc5isr(void); // RC5 ISR for remote control
void mute_isr(void);
+void mute_sel(void); //mutes select relays for a few ms during select
void recloop_isr(void);
-void select_isr(void);
void standby_out(void);
/****************************** volume increase ***********************************/
@@ -79,10 +96,27 @@
if ((standbyflag == TRUE) && (key_press < VUP_timeout)) {
FWD1 = HIGH;
- // FWD2 = HIGH;
wait(.1); //drive the motors for a short while
FWD1 = LOW;
- // FWD2 = LOW;
+
+ }
+ if (toggle1 != toggle) {
+ key_press = 0; // user released the button, so reset counter
+ } else if (toggle1 == toggle) {
+ key_press++; // button remained depressed, so increment counter
+ }
+ toggle1 = toggle;
+// wait_ms(1);
+}
+
+/******************************* volume decrease **********************************/
+void vol_dwn (void)
+{
+ if ((standbyflag == TRUE) && (key_press < VDWN_timeout)) {
+
+ REV1 = HIGH;
+ wait(.1); //drive the motors for a short while
+ REV1 = LOW;
}
if (toggle1 != toggle) {
key_press = 0; // user released the button, so reset counter
@@ -93,25 +127,6 @@
wait_ms(1);
}
-/******************************* volume decrease **********************************/
-void vol_dwn (void)
-{
- if ((standbyflag == TRUE) && (key_press < VDWN_timeout)) {
-
- REV1 = HIGH;
- // REV2 = HIGH;
- wait(.1); //drive the motors for a short while
- REV1 = LOW;
- // REV2 = LOW;
- }
- if (toggle1 != toggle) {
- key_press = 0; // user released the button, so reset counter
- } else if (toggle1 == toggle) {
- key_press++; // button remained depressed, so increment counter
- }
- toggle1 = toggle;
- wait_ms(1);
-}
/********************************** stdby_isr *************************************/
void stdby_isr(void)
{
@@ -121,54 +136,62 @@
/*********************************** standby **************************************/
/* this will require supporting hardware functionality to power down the */
/* analog board, LED's etc. Best option here is to use regulators with a */
-/* shutdown option. for now, all the LED's are just turned off. */
+/* shutdown option. for now, all the LED's are just turned off */
+/* and input relays and mute relayes disabled. */
void standby_out(void) // both p/button and R/C come in here
{
- stdby_int.fall(NULL); // on first power up cycle NO interuppts are accepted
- // and neither any while this function is executed in any case
- wait_ms(20); // a very simple debounce
+ __disable_irq();
+ stdby_int.fall(NULL); // on first power up cycle NO interrupts are accepted
+ wait_ms(DEBOUNCE); // a very simple debounce
do { // that waits for the depressed button to be released
- (1);
- } while (stdby !=1);
+ continue; //(1);
+ } while (stdby != 1);
- if (standbyflag == TRUE) { // was ON so we will turn it OFF
+ if (standbyflag == TRUE) { // was ON so now turn it OFF
+ stby_pa = LOW;
+ wait_ms(500); // make sure the power amp is OFF
+ muteind = LOW;
+ wait_ms(1000); // 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);
mute_int.fall(NULL);
recloop_int.fall(NULL);
- muteind = LOW;
- muteout = LOW;
- recloop_out = HIGH; // make sure the recloop is OFF [its active HIGH]
- select_save = select_drv; // save the status of select_drv
- select_drv = 0; // turn all input select realys OFF
- //power_ind = LOW; // this is the regulator shutdown control. HIGH = ON
- wait(1);
+ recloop_out = LOW; // make sure the recloop is OFF [its active HIGH]
+ 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);
+ select_drv = 0; // all input select relays are OFF
+ wait(3);
+ standbyflag = FALSE;
muteind = HIGH;
- standbyflag = FALSE; // set it up for the next power cycle
+ }
+ else if (standbyflag == FALSE) {// was OFF so we will turn it ON
- } else if (standbyflag == FALSE) { // was OFF so we will turn it ON
- //printf("Going thru power up\n\r");
- //power_ind = HIGH;
- muteind = LOW;
- rc5int.rise(&rc5isr); // trigger int on rising edge - go service it at rc5dat
+ muteind = LOW; // turn the mute indicator ON
+ rc5int.rise(&rc5isr); // trigger int on rising edge - go service it at rc5dat
select_int.fall(&select_isr); // input from rotary encoder or input select
mute_int.fall(&mute_isr);
recloop_int.fall(&recloop_isr);
- wait(2);
- select_drv = select_save; // recall the input select setting
- wait(2);
- muteind = HIGH; // let things settle a bit
- muteout = HIGH;
+// tone_pb.fall(tone_isr);
+ recloop_out = LOW; // make sure the recloop is OFF [its active HIGH]
+ wait_ms(100);
+ select_drv = select_save; // recall the input select setting and write to output
+ wait(2); // let things settle a bit
+ muteout = HIGH; // enable output
+ muteflag = TRUE;
+ muteind = HIGH; // turn the mute indicator OFF
standbyflag = TRUE;
- //printf("Finished powering up in standby_out\n\r");
+ stby_pa = HIGH; // now power up the amplifier
}
- wait_ms(5);
- stdby_int.fall(&stdby_isr); // re-enable the standby interrupt
- //printf("exiting standby_out handler now\n\r");
-
+ wait_ms(500); // let things settle a bit
+ __enable_irq();
+ stdby_int.fall(&stdby_isr); // re-enable the standby interrupt
+
}
/********************************** record loop isr *******************************/
@@ -177,117 +200,164 @@
{
FLAG5 = TRUE;
}
-/************************** recloop - just a simple toggle ************************/
+/********************************** recloop ***********************************/
void recloop()
{
- recloop_int.fall(NULL); // to prevent re-entrance when coming here from the R/C
- wait_ms(20); // simple debounce for when mute is via the f/p p/b switch
- do {
- (1); // wait here until the button is released
- } while (recloop_in!=1);
- recloop_out = !recloop_out;
- wait_ms(20);
+
+ if (select_drv != RECLOOP2) { // if its anything other than recloop we can activate the recloop relay
+ recloop_int.fall(NULL); // to prevent re-entrance when coming here from the R/C
+ wait_ms(DEBOUNCE); // simple debounce for when mute is via the f/p p/b switch
+
+ do {
+ continue; // wait here until the button is released
+ } while (recloop_in != 1);
+
+ if (recloop_rly == HIGH) { // the recloop relay was activated
+ recloop_rly = LOW; // so turn it off
+ recloop_out = LOW;
+ FLAG7 = 0;
+ }
+
+ else if (recloop_rly == LOW) { // it was OFF so activate it
+ recloop_rly = HIGH;
+ recloop_out = HIGH;
+ FLAG7 = 32;
+ }
+
+ wait_ms(DEBOUNCE);
+
+ }
+
recloop_int.fall(&recloop_isr);
+
}
-
/************************************ mute_isr ************************************/
void mute_isr(void)
{
FLAG3 = TRUE;
- toggle2 = !toggle2; // so the p/button input is recognized in mute_out()
-
+ toggle2 = !toggle2; // so the p/button input is recognized in mute_out()
+
}
-/*************************** mute - just a simple toggle **************************/
+/************************************** mute ************************************/
void mute_out()
{
- mute_int.fall(NULL); // to prevent re-entance when coming here from the R/C
- if ((standbyflag == TRUE) && (toggle != toggle2)) { // only toggle mute if the preamp is ON
- wait_ms(20); //simple debounce for when mute is via the f/p p/b switch
- do {
- (1); //wait here until the button is released
- } while (mute != 1);
- muteout = !muteout; // flip the mute relay
- muteind = !muteout; // Turn the indicator LED ON - it inverted compared to muteout
- wait_ms(20);
+ mute_int.fall(NULL); // to prevent re-entance when coming here from the R/C
+ wait_ms(DEBOUNCE); //simple debounce for when mute is via the f/p p/b switch
+ do {
+ continue; //wait here until the button is released
+ } while (mute != 1);
+ if (muteflag == FALSE) { // mute was inactive so it will now get activated
+ muteout = TRUE;
+ muteind = HIGH;
+ muteflag = TRUE; // indicate its been activated
}
- toggle2 = toggle;
- //toggle = toggle2;
+
+ else if (muteflag == TRUE) { //it was active, so it must be deactivated here
+ muteout = FALSE;
+ muteind = LOW;
+ muteflag = FALSE;
+ }
+
+ wait_ms(800); // make sure relay state is settled
+
mute_int.fall(&mute_isr);
}
/************************************ rc5isr **************************************/
-/* Interrupt triggered by a rising edge on p21 of the cont which is R/C data in */
+/* Interrupt triggered by a rising edge on p21 which is R/C data in */
void rc5isr(void)
{
FLAG1 = TRUE;
+ RCFLAG = TRUE;
+ REPEATFLAG = TRUE;
}
-/***************** save rc5 bit stream from remote controller *********************/
-/* This function reads the input data on pin rc5dat at 1778us ('tock')intervals */
+
+/******************* save bit stream from remote controller ***********************/
+/* This function reads the input data on pin rc5dat at 1120us ('tock')intervals */
/* and saves the data into an array stream[i]. */
-/* This function only looks at the second half of the bit position, since if that */
-/* is a 1 then it is assumed the first half of the bit position is a zero. Note */
-/* that in Manchester encoding, you cannot (should not) have both the 0 half-bit */
-/* position and the 1 half-bit position both HIGH or LOW in the same bit time - */
-/* a simplification exploited in this function. */
void save_stream(void)
{
- bool stream[15];// the array is initialized each time its used and is local only
+ if (RCFLAG == TRUE) {
+ wait_us(13500); // this is the AGC header - ignore
+ }
+
+ bool stream[32];// the array is initialized each time it is used and is local only
int bitloop; // number of bit positions
int i = 0; // counter
int k = 0; // temp storage
- startbit = 0;
+ vendor_id = 0;
+ pair_command = 0;
address = 0;
command = 0;
- toggle = 0;
- wait_us(tick); // locate read point in middle of 1st half bit time of the 1st start bit
- for (bitloop = 0; bitloop <15; bitloop++) {
+ stop_bit = 0; //must always return a 1 to be valid, so reset it
+ wait_us(tick); // locate read point in middle of 1st half bit time of the 1st start bit
+
+ for (bitloop = 0; bitloop <32; bitloop ++) {
+
stream[bitloop] = rc5dat; //read the data and save it to array position [i]
+ //stby_pa = !stby_pa; // for debugging - monitor stby_pa on pin 25
+ if (rc5dat == HIGH) {
+ wait_us(tock);
+ }
+
wait_us(tock); //wait here until ready to read the next bit in
-
- // now have 14 bits loaded into stream[i]
- }
+ } // now have 31 bits loaded into stream[i]
+
/* now put data in the array into the start, toggle, address and command variables - array counts from stream[0] */
- for (i=0; i<2; i++) { // first 2 bit positions are start bits = 3; will use this later for basic error checking
- k = stream[i];
- startbit = (startbit << 1);
- startbit = startbit|k;
+ for (i=0; i<11; i++) { // first 11 bit positions are vendor ID - always 043f for Apple; use for error checking later
+
+ k = stream[i]; // k will hold the vendor ID
+ vendor_id = (vendor_id << 1);
+ vendor_id = vendor_id|k;
+
}
- toggle = stream[2]; // 3rd bit position is the toggle bit - 1 bit
+ for (i = 11; i <16; i++) { // command or pair
+ k = stream[i];
+ pair_command = (pair_command << 1);
+ pair_command = pair_command|k;
+ }
- for (i = 3; i <8; i++) { // bit positions 3 to 7 are the address (or 'system') - 5 bit positions in total
+ for (i = 16; i <25; i++) { // device pairing address
k = stream[i];
address = (address << 1);
address = address|k;
}
- for (i = 8; i <14; i++) { // bit positions 8 to 13 are the command - 6 bit positions
+
+ for (i = 25; i <31; i++) { // bit positions 25 to 30 are the command - 7 bit positions
k = stream[i];
command = (command << 1);
command = command|k;
}
+ stop_bit = stream[31];
+
+ printf("\n vendor_id = %d pair_command = %d address = %d command = %d stop_bit = %d \r", vendor_id, pair_command, address, command, stop_bit);
}
+
/********************************* process_stream() *******************************/
/* handles commands coming in from the remote controller only */
void process_stream (void)
{
- if ((address == PREAMP) && (startbit == 3)) {
+ if ((RCFLAG == TRUE) && ((vendor_id == 479) || (vendor_id == 2047))) {
// basic error checking - must be preamp + startbit ok to get executed otherwise skip completly
- switch (command) {
+ switch (address) {
case VUP:
vol_up();
+ FLAGVOLUP = TRUE;
break;
case VDOWN:
vol_dwn();
+ FLAGVOLDWN = TRUE;
break;
case MUTE:
@@ -298,11 +368,27 @@
select_out();
break;
+ case SELECT_L:
+ select_out();
+ break;
+
case STANDBY:
standby_out();
break;
+
}
+
+ if ((FLAGVOLUP == TRUE) && (vendor_id == 2047)) {
+ vol_up();
+ }
+
+ if ((FLAGVOLDWN == TRUE) && (vendor_id ==2047)) {
+ vol_dwn();
+ }
+
}
+ RCFLAG = FALSE;
+
}
/*********************************** select_isr ***********************************/
@@ -311,84 +397,119 @@
FLAG2 = TRUE;
}
+/****************************** mute inter select*********************************/
+
+void mute_sel(void)
+{
+ select_drv = 0;
+ wait_ms(2);
+}
+
/********************************* select_process *********************************/
-/* used for selecting the input source. This function is used by both the */
-/* rotary encoder and the remote control */
+/* Used for selecting the input source. This function is used by the */
+/* rotary encoder only */
void select_process(void)
{
- if (RCFLAG == FALSE) { // if used R/C skip to select below
- wait_ms(5); // debounce
+
+ if (RCFLAG == FALSE) { // if used R/C skip completely - extra safety check
+ wait_ms(5); // 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
select = (select | selb);
+
+
+ switch (select) {
+ case 1: // select encoder is being rotated CW so increment select_rot
+ select_rot <<= 1;
+ if (select_rot > recloop_status ) {
+ select_rot = 1; // wrap around to 1
+ }
+
+ break;
+
+ case 0:
+ select_rot >>= 1; // encoder is being rotated CCW so decrement select_rot
+ if (select_rot < 1) {
+ select_rot = recloop_status; //wrap around to 32
+ }
+
+ break;
+
+ case 2:
+ break; // indeterminate fall through values - ignore
+ case 3:
+ break; // and do not change the output
+ }
}
- switch (select) {
- case 1: // select encoder is being rotated CW
- select_rot <<= 1;
- if (select_rot > 32) {
- select_rot = 1;
- }
- break;
+ select_rot = (select_rot | FLAG7);
+ select_drv = select_rot; // write the value out to the bus
- case 0:
- select_rot >>= 1; // encoder is being rotated CCW
- if (select_rot < 1) {
- select_rot = 32;
- }
- break;
-
- case 2:
- {} break; // indeterminate fall through values - ignore
- case 3:
- {} break;
- }
-
- select_drv = select_rot; // write the value out to the bus
+ // printf("\n RCFLAG %d \r", RCFLAG);
}
-/********************* input select from remote controller only *******************/
+
+
+/********************************* select_out *********************************/
+// this is only used by the IR remote
+
void select_out (void)
{
- if (toggle != toggle1) { // if the R/C button is held down, skip the increment
- RCFLAG = TRUE; // this indicates command came in through the remote
- select = 1;
- select_process();
- RCFLAG = FALSE;
+
+ if (address == SELECT_L) {
+ select_rot >>= 1;
+ if (select_rot <1) {
+ select_rot = 32;
+ }
}
- toggle1 = toggle;
+
+
+ if (address == SELECT_R) {
+ select_rot <<= 1;
+ if (select_rot >32) {
+ select_rot = 1;
+ }
+
+ }
+
+ select_drv = (select_rot | FLAG7); //write the selection out to the bus.
+
+// printf("\n select_rot = %d select_drv = %d\r", select_rot, select_drv);
+
}
+
/************************************ main() ***************************************/
int main(void)
{
- __disable_irq(); // just to make sure we can set up correctly without problems
-
- mute_int.mode(PullUp); // pin 11 on LPC1114
- rc5dat.mode(PullUp); // pin 15
- sela.mode(PullUp); // pin 28
- selb.mode(PullUp); // pin 27
- stdby.mode(PullUp); // pin 26
- recloop_in.mode(PullUp); // pin 15
- //TXD.mode(PullUp); // pin 16
-
-
- //muteind = LOW;
- muteout = LOW; // mute the output while we go through power-up sequence
- recloop_out = HIGH; // make sure initial recloop condition is delected - this is open drain O/PO
- //power_ind = LOW; // power control; HIGH = power up
- //wait(.2);
- //Serial pc(USBTX, USBRX); // for debuging only - comment out on production
+ Serial pc(USBTX, USBRX);
+ __disable_irq(); // just to make sure we can set up correctly without problems
+ stby_pa = LOW; // make sure the power aamp is OFF
+ 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
+ muteind = LOW; //mute LED must be ON - power up preamble
+ select_drv = 0;
+ recloop_out = LOW; // make sure the recloop LED is OFF [its active HIGH]
+ recloop_rly = LOW; // make sure the recloop relay is OFF
+
+ mute_int.mode(PullUp); // set up all the pin states per Pindef1114.h
+ rc5dat.mode(PullUp); // pin 17
+ sela.mode(PullUp); // pin 28
+ selb.mode(PullUp); // pin 27
+ stdby.mode(PullUp); // pin 26
+ recloop_in.mode(PullUp); // pin 14
+
+ wait(.2);
FLAG1 = FALSE;
FLAG2 = FALSE;
- FWD1=0; //make sure the volume control motor is OFF
+ FLAG5 = FALSE; // this is the recloop flag
+ FWD1=0; //make sure the volume control motor is OFF
REV1=0;
-
- // set up the ISR's we will be using
- rc5int.rise(&rc5isr); // trigger int on rising edge - go service it at rc5dat
+ // set up the ISR's that will be used
+ rc5int.fall(&rc5isr); // trigger int on rising edge - go service it at rc5dat
select_int.fall(&select_isr); // input from rotary encoder or input select
mute_int.fall(&mute_isr); // mute push button interrupt
recloop_int.fall(&recloop_isr); // record loop push button interrupt
@@ -399,68 +520,53 @@
mute_int.fall(NULL);
recloop_int.fall(NULL);
-//printf("disable ISR\n");
-
standbyflag = TRUE; // preamp will be set-up first time for OFF
- standby_out(); // go through standby_out for initial set-up
- select_save = 2; // CD will be selected when power is first turned on
- //muteind = HIGH;
+ standby_out(); // set system up
+ standbyflag = FALSE;
+ select_save = 2;
+ select_rot = select_save; // CD will be selected when power is first turned on
+ wait(3);
+ muteind = HIGH;
__enable_irq();
+// all ready and in standby from this point forward
- // all ready and in standby from this point forward
+// note: if printf is used for debug, the record indicate LED will remain ON after printing
+// the first message
LOOP: // this is the main operating loop
-
-//printf("WFI . . . . %i\n\r", loop_counter);
__WFI(); // wait here until interrupt
if (FLAG1 == TRUE) { // FLAG1 indicates remote control was used
- __disable_irq();
save_stream();
- if (startbit == 3) {
- process_stream();
- }
+ process_stream();
+
FLAG1 = FALSE;
- __enable_irq();
}
if (FLAG2 == TRUE) {
- __disable_irq();
select_process(); //select process
FLAG2 = FALSE;
- __enable_irq();
}
if (FLAG3 == TRUE) {
- __disable_irq();
mute_out(); //mute
FLAG3 = FALSE;
- __enable_irq();
}
-//printf("B4stdby\n\r");
- if (FLAG4 == TRUE) {
- __disable_irq();
- standby_out();
- FLAG4 = FALSE;
- __enable_irq(); // standby
-
-// printf("back from isr\n\r");
- //__enable_irq();
-//printf("re-enable isr straight after back from standby\n\r");
+
+ if (FLAG4 == TRUE) { // standby ON/OFF
+ standby_out();
+ FLAG4 = FALSE;
}
-//printf("finished with STBY\n");
+
if (FLAG5 == TRUE) {
- __disable_irq();
recloop(); //recloop
FLAG5 = FALSE;
- __enable_irq();
}
- wait_us(5);
-//printf("loop to WFI\n\r");
-// loop_counter++;
+ //printf("\r Command = %d Address = %d \n",command, address);
+
goto LOOP;
}
--- a/mbed.bld Fri Nov 20 14:36:14 2015 +0000 +++ b/mbed.bld Tue Jul 26 16:24:40 2022 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file
--- a/rc5codes.h Fri Nov 20 14:36:14 2015 +0000 +++ b/rc5codes.h Tue Jul 26 16:24:40 2022 +0000 @@ -19,11 +19,13 @@ // and be ignored by the decoder. Only the ones un-commented out below are active in V1.0 // Note you will also need to write the associated command processor functions -#define STANDBY 12 // toggle power ON and OFF -#define MUTE 13 // toggle output signal on and off +#define STANDBY 378 // toggle power ON and OFF +#define MUTE 442 // toggle output signal on and off // #define 14 PRESETS -#define VUP 16 -#define VDOWN 17 +#define VUP 464 +#define VDOWN 432 +//#define TONE 22 + // #define 18 BRIGHTNESS + // #define 19 BRIGHTNESS - // #define 20 COLOR SATURATION + @@ -40,7 +42,13 @@ // #define PLAY 53 // #define STOP 54 // #define 55 RECORD -#define SELECT_R 3 // rotates input through inputs - must depress and then release each time + +#define SELECT_R 480 // rotates input through inputs - must depress and then release each time +#define SELECT_L 272 // rotates input through inputs - must depress and then release each time + +//#define DAC_FIL 20 +//#define BLUTOOTH 18 +//#define SYSTEM 16 /* RC5 address */ // #define 0 TV SET 1 @@ -58,8 +66,8 @@ // #define 12 CD VIDEO // #define 13 RESERVED // #define 14 CD PHOTO -// #define RESERVED -#define PREAMP 16 +// #define 23 RESERVED // this is the official RC5 designation for system code 13 +#define PREAMP 479 // this is the system code identifying an Apple Remote // #define RECEIVER 17 // #define 18 TAPE / CASSETE RECORDER // #define PRE2 19 @@ -70,7 +78,7 @@ // #define 24 RESERVED // #define 25 RESERVED // #define 26 WRITABLE CD -// #define 26-31 RESERVED0 TV SET 1 +// #define 26-31 RESERVED FOR TV SET 1 @@ -79,3 +87,7 @@ + + + +