/* ** =================================================================== ** Method : HWEnDi (component ADC) ** ** Description : ** Enables or disables the peripheral(s) associated with the ** component. The method is called automatically as a part of ** Enable, Disable and Init methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static void HWEnDi(void) { if (AD1_ModeFlg) { /* Launch measurement? */ OutFlg = FALSE; /* Measured values are available */ setRegBits(ADC_ADSTAT,2048); /* Clear flag */ clrRegBit(ADC_ADCR1,STOP0); /* Normal operation mode */ setRegBit(ADC_ADCR1,START0); /* Launching of conversion */ } else { setRegBit(ADC_ADCR1,STOP0); /* Stop command issued */ } }
/** * Enables the PWM pad and clears fault pins. * @return ERR_OK always. */ byte PWMC1_outputPadEnable (void) { setRegBit (PWMB_PMOUT, PAD_EN); #ifndef EMERGENCY_DISABLED setReg (PWMB_PMFSA, 0x55); #endif return ERR_OK; }
void resetCPU(CPU *c){ //resets CPU to initial state as if it has just been initialized int NUM_REG = 5; memset(c->regs, 0, NUM_REG*sizeof(int8_t)); int ADDR_SPACE_SIZE = 65536; memset(c->addressSpace, 0, ADDR_SPACE_SIZE*sizeof(int8_t)); c->PC = 0; setRegBit(c, STATUS, 5, 1); }
void PWM_B_outputPadEnable (word mask) { DutyCycle[1].Duty = MIN_DUTY; DutyCycleReq[1].Duty = MIN_DUTY; PWM_generate_BLL(1,DutyCycle[1].Duty); setRegBit(PWMB_PMOUT,PAD_EN); reset_faults_PWMB(); }
/** * 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 */ } }
/* ** =================================================================== ** Method : HWEnDi (component SynchroMaster) ** ** Description : ** Enables or disables the peripheral(s) associated with the bean. ** The method is called automatically as a part of the Enable and ** Disable methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static void HWEnDi(void) { if (EnUser) { /* Enable device? */ setRegBit(QSPI0_SCTRL,SPE); /* Enable device */ setRegBits(GPIO_C_PEREN,0x0200); /* Switch pin to peripheral */ if (SerFlag & FULL_TX) { /* Is any char in transmit buffer? */ setReg(QSPI0_DXMIT,BufferWrite); /* Store char to transmitter register */ SerFlag &= ~FULL_TX; /* Zeroize FULL_TX flag */ } } else { clrRegBits(GPIO_C_PEREN,0x0200); /* Switch pin to GPIO */ clrRegBit(QSPI0_SCTRL,SPE); /* Disable device */ } }
/* CPU initializer */ CPU * getCPU(){ CPU *c = malloc(sizeof(CPU)); //programs start at 0x600 in memory c->PC = 0; //initialize 8 bit registers int NUM_REG = 5; int8_t *r = calloc(NUM_REG,sizeof(int8_t)); c-> regs = r; //initialize address space int ADDR_SPACE_SIZE = 65536; int8_t *a= calloc(ADDR_SPACE_SIZE,sizeof(int8_t)); c-> addressSpace = a; //set bit 5 of status register to 1 //to match specifications setRegBit(c, STATUS, 5, 1); //initialize stack pointer to 256 (it grows downwards //towards zero) setRegByte(c, STACK, 0xFF); return c; }
void setFlag(CPU *c, FLAG name, int8_t val){ //bit 5 of the status register is not to be set //and should always be 1 assert(name != NOT_USED_FLAG); setRegBit(c, STATUS, name, val); }
/** * stops the acquisition, disables interrupts. * use init to start acquisition again. * **************************************************************************************/ byte AD_stopAcquisitionA(void) { setRegBit (ADCA_ADCR1, STOP); /* Stop command issued */ return ERR_OK; }
/* ** =================================================================== ** Method : HWEnDi (component TimerInt) ** ** Description : ** Enables or disables the peripheral(s) associated with the bean. ** The method is called automatically as a part of the Enable and ** Disable methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static void HWEnDi(void) { setRegBit(PIT0_CTRL,CNT_EN); /* Run counter */ }