/** * This method enables the PWM generation on the specified channel * @param axis is the axis number ***************************************************************************/ void PWM_outputPadEnable(byte axis) { Int16 status=0; can_printf("PWMEN CH%d", axis); status = getReg (PWMA_PMFSA); if ((axis == 0) && !(status & PWMA_PMFSA_FPIN3_MASK)) { if (getRegBit(PWMA_PMOUT,PAD_EN)) { led0_on _pad_enabled[0]= true; return; } led0_on _pad_enabled[0]= true; PWM_A_outputPadEnable(ALL_CHANNELS); } status = getReg (PWMB_PMFSA); if ((axis == 1) && !(status & PWMB_PMFSA_FPIN3_MASK)) { if (getRegBit(PWMB_PMOUT,PAD_EN)) { led2_on _pad_enabled[1]= true; return; } led2_on _pad_enabled[1]= true; PWM_B_outputPadEnable(ALL_CHANNELS); } FaultInterruptEnable(axis); }
void bootExit(void) { int i=0; sci_tx(StrNewLine); sci_tx(&StrStarted[0]); sci_tx(StrNewLine); while(!getRegBit(SCI_STAT,TIDLE)){}; // wait until all data has been sent // Disable all interrupts Cpu_DisableInt(); // Disable timer //Timer_Disable(); // Restore Vector Base Address (VBA) INTC_VBA = 0; // Restore GPIO A register to reset value GPIO_A_DDR &= ~GPIO_A_DDR_DD0_MASK; // set low GPIO_A_DDR &= ~GPIO_A_DDR_DD1_MASK; /**************************************************************************** / read user start address /****************************************************************************/ StartAddress = pmem_read((unsigned int *)BOOT_START_ADDRESS_PLACE); asm(move.l StartAddress, N); asm(jmp (N)); }
/* ** =================================================================== ** Method : Inhr6_SendChar (component AsynchroSerial) ** ** Description : ** Sends one character to the channel. If the bean is ** temporarily disabled (Disable method) SendChar method ** only stores data into an output buffer. In case of a zero ** output buffer size, only one character can be stored. ** Enabling the bean (Enable method) starts the transmission ** of the stored data. This method is available only if the ** transmitter property is enabled. ** Version specific information for Freescale 56800 ** derivatives ] ** DMA mode: ** If DMA controller is available on the selected CPU and ** the transmitter is configured to use DMA controller then ** this method only sets selected DMA channel. Then the ** status of the DMA transfer can be checked using ** GetCharsInTxBuf method. See an example of a typical usage ** for details about communication using DMA. ** Parameters : ** NAME - DESCRIPTION ** Chr - Character to send ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** ERR_TXFULL - Transmitter is full ** =================================================================== */ byte Inhr6_SendChar(Inhr6_TComData Chr) { if (!getRegBit(SCI_STAT, TDRE)) { /* Is the transmitter empty? */ return ERR_TXFULL; /* If yes then error */ } setReg(SCI_DATA, Chr); /* Store char to transmitter register */ return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : AS1_SendChar (component AsynchroSerial) ** Description : ** Sends one character to the channel. If the component is ** temporarily disabled (Disable method) SendChar method only ** stores data into an output buffer. In case of a zero output ** buffer size, only one character can be stored. Enabling the ** component (Enable method) starts the transmission of the ** stored data. This method is available only if the ** transmitter property is enabled. ** Version specific information for Freescale 56800 derivatives ** DMA mode: ** If DMA controller is available on the selected CPU and the ** transmitter is configured to use DMA controller then this ** method only sets selected DMA channel. Then the status of ** the DMA transfer can be checked using GetCharsInTxBuf method. ** See an example of a typical usage for details about ** communication using DMA. ** Parameters : ** NAME - DESCRIPTION ** Chr - Character to send ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** ERR_TXFULL - Transmitter is full ** =================================================================== */ byte AS1_SendChar(AS1_TComData Chr) { if ((getRegBit(SCI_SCISR, TDRE) == 0U)) { /* Is the transmitter empty? */ return ERR_TXFULL; /* If yes then error */ } setReg(SCI_SCIDR, Chr); /* Store char to transmitter register */ return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : MainMeasure (component ADC) ** ** Description : ** The method performs A/D conversion(s). The method is called ** automatically as a part of measure methods or the HWEnDi ** method. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static void MainMeasure(void) { if (getRegBit(ADC_ADSTAT,EOSI0)) { /* Is a scan cycle completed? */ setRegBits(ADC_ADSTAT,2048); /* Clear EOSI flag */ OutFlg = TRUE; /* Measured values are available */ AD1_ModeFlg = IDLE; /* Set the component to the idle mode */ } }
/* ** =================================================================== ** Method : Resolver_SendChar (component SynchroMaster) ** ** Description : ** Sends one character to the channel. ** Version specific information for Freescale 56800 derivatives ** ] ** DMA mode: ** If DMA controller is available on the selected CPU and the ** transmitter is configured to use DMA controller then this ** method only sets the selected DMA channel. The status of the ** DMA transfer can then be checked using GetCharsInTxBuf ** method. See the typical usage for details about ** communication using DMA. ** Parameters : ** NAME - DESCRIPTION ** Chr - Character to send ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** ERR_DISABLED - Device is disabled (only if ** output DMA is supported and enabled) ** ERR_TXFULL - Transmitter is full ** =================================================================== */ byte Resolver_SendChar(Resolver_TComData Chr) { if ((!getRegBit(QSPI0_SCTRL,SPTE))||(SerFlag&FULL_TX)) { /* Is last character send? */ return ERR_TXFULL; /* If no then return error */ } if (EnUser) { /* Is device enabled? */ setReg(QSPI0_DXMIT,Chr); /* If yes, send character */ } else { BufferWrite = Chr; /* If no, save character */ SerFlag |= FULL_TX; /* ...and set flag */ } return ERR_OK; /* OK */ }
void AD_interruptCCB(void) { _sample_B[0] = (getReg(ADCB_ADRSLT0)); _sample_B[1] = (getReg(ADCB_ADRSLT1)); _sample_B[2] = (getReg(ADCB_ADRSLT2)); setReg(ADCB_ADSTAT, 0x0800); /* Clear EOSI flag */ OutFlgB = TRUE; /* Measured values are available */ if (!(getRegBit(ADCB_ADCR1, SMODE2))) { /* Not running in trigger mode? */ ad_ModeFlgB = IDLE; /* Set the bean to the idle mode */ } }
void AD_interruptCCA(void) { _sample_A[0] = (getReg(ADCA_ADRSLT0)); _sample_A[1] = (getReg(ADCA_ADRSLT1)); _sample_A[2] = (getReg(ADCA_ADRSLT2)); // _sample_A[3] = (getReg(ADCA_ADRSLT3)); // _sample_A[4] = (getReg(ADCA_ADRSLT4)); // _sample_A[5] = (getReg(ADCA_ADRSLT5)); _sample_A[6] = (getReg(ADCA_ADRSLT6)); _sample_A[7] = (getReg(ADCA_ADRSLT7)); setReg(ADCA_ADSTAT, 0x0800); /* Clear EOSI flag */ OutFlgA = TRUE; /* Measured values are available */ if (!(getRegBit(ADCA_ADCR1, SMODE2))) { /* Not running in trigger mode? */ ad_ModeFlgA = IDLE; /* Set the bean to the idle mode */ } }
void _sleepEntryPoint(void) { /*** ### 56F807 "Cpu" init code ... ***/ /* System clock initialization */ setReg(PLLCR, (PLLCR_LCKON_MASK | PLLCR_ZSRC0_MASK)); /* Enable PLL, LCKON and select clock source from prescaler */ /* CLKOSR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,CLKOSEL=0 */ setReg16(CLKOSR, 0); /* CLKO = ZCLOCK */ /* PLLDB: LORTP=0,PLLCOD=0,PLLCID=1,??=0,PLLDB=39 */ setReg16(PLLDB, 295); /* Set the clock prescalers */ while(!getRegBit(PLLSR, LCK0)){} /* Wait for PLL lock */ setReg(PLLCR, (PLLCR_LCKON_MASK | PLLCR_ZSRC1_MASK)); /* Select clock source from postscaler */ /* External bus initialization */ /* BCR: ??=0,??=0,??=0,??=0,??=0,??=0,DRV=1,??=0,WSX=12,WSP=12 */ setReg16(BCR, 716); /* Bus control register */ asm(move #1,y1) /* stores y1=1 for jumping * to mySleep after initialization */ asm(jmp init_56800_); /* Jump to C startup code */ }
//////////////////////////////////////////////////////////////////////// // // comMainLoop() // // Communication loop. Wait for CAN frames and parses the messagge. // The loop ends when comContinue is false. // //////////////////////////////////////////////////////////////////////// void comMainLoop(void) { byte ReadCANState; byte i; comContinue = TRUE; comTimerEn = TRUE; while (comContinue) { /* wait CAN data or while timer expired, if set */ while (CAN1_getStateRX() == 0) { // Timer check if (comTimerEn) { if (getRegBit(TMRC1_SCR,TCF)) /* Is the interrupt request flag set? */ { clrRegBit(TMRC1_SCR,TCF); /* If yes then reset this flag */ if (--TmpXdataVar == 0) { setRegBitGroup(TMRC0_CTRL,CM,0); /* Stop counter */ return; } } } } if (CAN1_getStateRX() != 0) { /* Received CAN frame */ ReadCANState=CAN1_readFrame (&comBuffer.CAN_messID, &comBuffer.CAN_length, comBuffer.CAN_data); if ((ReadCANState != ERR_OK) && (ReadCANState != ERR_RXEMPTY)) { userError(INDICATE_ERROR_RECEIVE); } sprsReady(&comBuffer); /* call CAN protocol parser */ } } /* while */ }
/** * starts the acquisition on channel A. * **************************************************************************************/ static void HWEnDiA(void) { if (ad_ModeFlgA) /* Launch measurement? */ { OutFlgA = FALSE; /* Measured values are available */ /* Trigger mode? */ if (getRegBit (ADCA_ADCR1, SMODE2)) { setRegBit (ADCA_ADCR1, SYNC); /* Use sync input to initiate a conversion */ clrRegBit (ADCA_ADCR1, STOP); /* Normal operation mode */ } else { /* Set normal operation mode and sync input disabled */ clrRegBits (ADCA_ADCR1, ADCA_ADCR1_SYNC_MASK | ADCA_ADCR1_STOP_MASK); setRegBit (ADCA_ADCR1, START); /* Launching of conversion */ } } else { setRegBit (ADCA_ADCR1, STOP); /* Stop command issued */ } }
int8_t getFlag(CPU *c, FLAG name){ //bit 5 of the status register is not to be set //and should always be 1 assert(name != NOT_USED_FLAG); return getRegBit(c, STATUS, name); }
/* ** =================================================================== ** Method : AS1_GetCharsInTxBuf (component AsynchroSerial) ** Description : ** Returns the number of characters in the output buffer. This ** method is available only if the transmitter property is ** enabled. ** Version specific information for Freescale 56800 derivatives ** DMA mode: ** If DMA controller is available on the selected CPU and the ** transmitter is configured to use DMA controller then this ** method returns the number of characters in the transmit ** buffer. ** Parameters : None ** Returns : ** --- - The number of characters in the output ** buffer. ** =================================================================== */ word AS1_GetCharsInTxBuf(void) { return (word)((getRegBit(SCI_SCISR, TDRE) == 0U)? 1 : 0); /* Return number of chars in the transmitter buffer */ }
/* ** =================================================================== ** Method : AS1_GetCharsInRxBuf (component AsynchroSerial) ** Description : ** Returns the number of characters in the input buffer. This ** method is available only if the receiver property is enabled. ** Version specific information for Freescale 56800 derivatives ** DMA mode: ** If DMA controller is available on the selected CPU and the ** receiver is configured to use DMA controller then this ** method returns the number of characters in the receive ** buffer. ** Parameters : None ** Returns : ** --- - The number of characters in the input ** buffer. ** =================================================================== */ word AS1_GetCharsInRxBuf(void) { return (word)((getRegBit(SCI_SCISR, RDRF) != 0U)? 1 : 0); /* Return number of chars in receive buffer */ }
/* ** =================================================================== ** Method : Inhr6_GetCharsInRxBuf (component AsynchroSerial) ** ** Description : ** Returns the number of characters in the input buffer. ** This method is available only if the receiver property is ** enabled. ** Version specific information for Freescale 56800 ** derivatives ] ** DMA mode: ** If DMA controller is available on the selected CPU and ** the receiver is configured to use DMA controller then ** this method returns the number of characters in the ** receive buffer. ** Parameters : None ** Returns : ** --- - The number of characters in the input ** buffer. ** =================================================================== */ word Inhr6_GetCharsInRxBuf(void) { return (word)((getRegBit(SCI_STAT, RDRF) != 0)? 1 : 0); /* Return number of chars in receive buffer */ }
/* ** =================================================================== ** Method : Resolver_GetCharsInTxBuf (component SynchroMaster) ** ** Description : ** Returns the number of characters in the output buffer. ** Version specific information for Freescale 56800 derivatives ** ] ** DMA mode: ** If DMA controller is available on the selected CPU and the ** transmitter is configured to use DMA controller then this ** method returns the number of characters in the transmit ** buffer. ** Parameters : None ** Returns : ** --- - Number of characters in the output buffer. ** =================================================================== */ word Resolver_GetCharsInTxBuf(void) { return ((word)((EnUser) ? (getRegBit(QSPI0_SCTRL,SPTE)?0:1) : ((SerFlag & FULL_TX)?1:0))); /* Return number of chars in the transmit buffer */ }