Ejemplo n.º 1
0
Archivo: Cpu.c Proyecto: mofo/ReVario
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MK20DX128EX5)
**
**     Description :
**         Initializes beans and provides common register initialization. 
**         The method is called automatically as a part of the 
**         application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
      /* Initialization of the SIM module */
  /* PORTA_PCR4: ISF=0,MUX=7 */
  PORTA_PCR4 = (uint32_t)((PORTA_PCR4 & (uint32_t)~(uint32_t)(
                PORT_PCR_ISF_MASK
               )) | (uint32_t)(
                PORT_PCR_MUX(0x07)
               ));
        /* Initialization of the RCM module */
  /* RCM_RPFW: RSTFLTSEL=0 */
  RCM_RPFW &= (uint8_t)~(uint8_t)(RCM_RPFW_RSTFLTSEL(0x1F));
  /* RCM_RPFC: RSTFLTSS=0,RSTFLTSRW=0 */
  RCM_RPFC &= (uint8_t)~(uint8_t)(
               RCM_RPFC_RSTFLTSS_MASK |
               RCM_RPFC_RSTFLTSRW(0x03)
              );
        /* Initialization of the FTFL_FlashConfig module */
      /* Initialization of the PMC module */
  /* PMC_REGSC: ACKISO=0,BGBE=0 */
  PMC_REGSC &= (uint8_t)~(uint8_t)(
                PMC_REGSC_ACKISO_MASK |
                PMC_REGSC_BGBE_MASK
               );
  /* PMC_LVDSC1: LVDACK=1,LVDIE=0,LVDRE=1,LVDV=0 */
  PMC_LVDSC1 = (uint8_t)((PMC_LVDSC1 & (uint8_t)~(uint8_t)(
                PMC_LVDSC1_LVDIE_MASK |
                PMC_LVDSC1_LVDV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC1_LVDACK_MASK |
                PMC_LVDSC1_LVDRE_MASK
               ));
  /* PMC_LVDSC2: LVWACK=1,LVWIE=0,LVWV=0 */
  PMC_LVDSC2 = (uint8_t)((PMC_LVDSC2 & (uint8_t)~(uint8_t)(
                PMC_LVDSC2_LVWIE_MASK |
                PMC_LVDSC2_LVWV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC2_LVWACK_MASK
               ));
  /* SMC_PMPROT: ??=0,??=0,AVLP=0,??=0,ALLS=0,??=0,AVLLS=0,??=0 */
  SMC_PMPROT = 0x00U;                  /* Setup Power mode protection register */
  /* Common initialization of the CPU registers */
  /* NVICIP8: PRI8=0 */
  NVICIP8 = NVIC_IP_PRI8(0x00);
  /* SCB_SHPR2: PRI_11=0 */
  SCB_SHPR2 &= (uint32_t)~(uint32_t)(SCB_SHPR2_PRI_11(0xFF));
  /* ### Asynchro serial "AS1" init code ... */
  AS1_Init();
  /* ### InternalI2C "CI2C0" init code ... */
  CI2C0_Init();
  /* ### Asynchro serial "AS0" init code ... */
  AS0_Init();
  /* ### SynchroMaster "SM1" init code ... */
  SM1_Init();
  /* Enable interrupts of the given priority level */
  Cpu_SetBASEPRI(0U);
}
Ejemplo n.º 2
0
static void Init(void) {
    /* initialize struct fields */
    deviceData.handle = AS1_Init(&deviceData);
    deviceData.isSent = FALSE;
    deviceData.rxChar = '\0';
    deviceData.rxPutFct = RxBuf_Put;
    /* set up to receive RX into input buffer */
    RxBuf_Init(); /* initialize RX buffer */
    /* Set up ReceiveBlock() with a single byte buffer. We will be called in OnBlockReceived() event. */
    while(AS1_ReceiveBlock(deviceData.handle, (LDD_TData *)&deviceData.rxChar, sizeof(deviceData.rxChar))!=ERR_OK) {} /* initial kick off for receiving data */
}
Ejemplo n.º 3
0
void main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
  serialHandle = AS1_Init(NULL);
  CDC_Run();

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
Ejemplo n.º 4
0
static void Init(void) {
	Frame.Data = rxbuffer; /* Set pointer to OutData buffer */

	// Inicializacion UART
	uartData.handle = AS1_Init(&uartData);
	uartData.isSent = FALSE;
	uartData.rxChar = '\0';
	uartData.rxPutFct = UART_RxBuff_Put;

	canData.handle = CAN1_Init(&canData);
	canData.isSent = FALSE;
	canData.rxChar = '\0';
	canData.rxPutFct = CAN_RxBuff_Put;

	/* set up to receive RX into input buffer */
	UART_RxBuff_Init(); /* initialize RX buffer */
	CAN_RxBuff_Init(); /* initialize RX buffer */

	/* Set up ReceiveBlock() with a single byte buffer. We will be called in OnBlockReceived() event. */
	while (AS1_ReceiveBlock(uartData.handle, (LDD_TData *) &uartData.rxChar,
			sizeof(uartData.rxChar)) != ERR_OK) {
	} /* initial kick off for receiving data */
}
Ejemplo n.º 5
0
float rotSpeed = 0;
float penSpeed = 0;  // these are local variables for Function SteppermotorMove-Command, but for performance-reasons it will be initialized here

static void Init(void)
{
  /* initialize struct fields */
  deviceData.handle = AS1_Init (&deviceData);
  deviceData.isSent = FALSE;
  deviceData.rxChar = '\0';
  deviceData.rxPutFct = RxBuf_Put;

  /* set up to receive RX into input buffer */
  //  RxBuf_Init(); /* initialize RX buffer */
  /* Set up ReceiveBlock() with a single byte buffer. We will be called in OnBlockReceived() event. */
  while (AS1_ReceiveBlock (deviceData.handle, (LDD_TData *) &deviceData.rxChar,
                           sizeof(deviceData.rxChar)) != ERR_OK)
  {
  } /* initial kick off for receiving data */


  AccelStepper_Init (&rotMotor, STEP1_PIN, DIR1_PIN);
  AccelStepper_Init (&penMotor, STEP2_PIN, DIR2_PIN);
Ejemplo n.º 6
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MK22FN1M0LQ12)
**
**     Description :
**         Initializes beans and provides common register initialization. 
**         The method is called automatically as a part of the 
**         application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
      /* Initialization of the SIM module */
  /* PORTA_PCR4: ISF=0,MUX=7 */
  PORTA_PCR4 = (uint32_t)((PORTA_PCR4 & (uint32_t)~(uint32_t)(
                PORT_PCR_ISF_MASK
               )) | (uint32_t)(
                PORT_PCR_MUX(0x07)
               ));
        /* Initialization of the RCM module */
  /* RCM_RPFW: RSTFLTSEL=0 */
  RCM_RPFW &= (uint8_t)~(uint8_t)(RCM_RPFW_RSTFLTSEL(0x1F));
  /* RCM_RPFC: RSTFLTSS=0,RSTFLTSRW=0 */
  RCM_RPFC &= (uint8_t)~(uint8_t)(
               RCM_RPFC_RSTFLTSS_MASK |
               RCM_RPFC_RSTFLTSRW(0x03)
              );
  /* SIM_SCGC7: MPU=1 */
  SIM_SCGC7 |= SIM_SCGC7_MPU_MASK;
        /* Initialization of the MPU module */
  /* MPU_CESR: SPERR=0,VLD=0 */
  MPU_CESR &= (uint32_t)~(uint32_t)((MPU_CESR_SPERR(0x1F) | MPU_CESR_VLD_MASK));
      /* Initialization of the PMC module */
  /* PMC_LVDSC1: LVDACK=1,LVDIE=0,LVDRE=1,LVDV=0 */
  PMC_LVDSC1 = (uint8_t)((PMC_LVDSC1 & (uint8_t)~(uint8_t)(
                PMC_LVDSC1_LVDIE_MASK |
                PMC_LVDSC1_LVDV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC1_LVDACK_MASK |
                PMC_LVDSC1_LVDRE_MASK
               ));
  /* PMC_LVDSC2: LVWACK=1,LVWIE=0,LVWV=0 */
  PMC_LVDSC2 = (uint8_t)((PMC_LVDSC2 & (uint8_t)~(uint8_t)(
                PMC_LVDSC2_LVWIE_MASK |
                PMC_LVDSC2_LVWV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC2_LVWACK_MASK
               ));
  /* PMC_REGSC: BGEN=0,ACKISO=0,BGBE=0 */
  PMC_REGSC &= (uint8_t)~(uint8_t)(
                PMC_REGSC_BGEN_MASK |
                PMC_REGSC_ACKISO_MASK |
                PMC_REGSC_BGBE_MASK
               );
  /* SMC_PMPROT: ??=0,??=0,AVLP=0,??=0,ALLS=0,??=0,AVLLS=0,??=0 */
  SMC_PMPROT = 0x00U;                  /* Setup Power mode protection register */
  /* Common initialization of the CPU registers */
  /* NVICIP59: PRI59=0 */
  NVICIP59 = NVIC_IP_PRI59(0x00);
  /* NVICIP53: PRI53=0 */
  NVICIP53 = NVIC_IP_PRI53(0x00);
  /* NVICIP20: PRI20=0 */
  NVICIP20 = NVIC_IP_PRI20(0x00);
  /* GPIOA_PDDR: PDD&=~0x4000 */
  GPIOA_PDDR &= (uint32_t)~(uint32_t)(GPIO_PDDR_PDD(0x4000));
  /* PORTE_PCR26: ISF=0,MUX=7 */
  PORTE_PCR26 = (uint32_t)((PORTE_PCR26 & (uint32_t)~(uint32_t)(
                 PORT_PCR_ISF_MASK
                )) | (uint32_t)(
                 PORT_PCR_MUX(0x07)
  ));
  /* ### BitIO_LDD "BitIoLdd1" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd1_Init(NULL);
  /* ### LEDbit "LED1" init code ... */
  LED1_Init(); /* initializes the driver */
  /* ### BitIO_LDD "BitIoLdd2" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd2_Init(NULL);
  /* ### LEDbit "LED2" init code ... */
  LED2_Init(); /* initializes the driver */
  /* ### CriticalSection "CS1" init code ... */
  /* ### HardFault "HF1" init code ... */
  /* Write code here ... */
  /* ### TimerInt_LDD "TimerIntLdd1" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)TimerIntLdd1_Init(NULL);
  /* ### TimerInt "TI1" init code ... */
  /* ### Asynchro serial "AS1" init code ... */
  AS1_Init();
  /* ### Shell "CLS1" init code ... */
  CLS1_Init(); /* initialize shell */
  /* ### ExtInt_LDD "ExtIntLdd1" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)ExtIntLdd1_Init(NULL);
  /* ### BitIO_LDD "BitIoLdd4" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd4_Init(NULL);
  /* ### Init_GPIO "PTA" init code ... */
  PTA_Init();


  /* ### Asynchro serial "Serial1" init code ... */
  Serial1_Init();
  /* ### Bluetooth_EGBT "BT1" init code ... */
  BT1_Init();
  /* ### Init_USB_OTG "USB0" init code ... */
  USB0_Init();


  /* ### RingBuffer "Tx1" init code ... */
  Tx1_Init();
  /* ### RingBuffer "Rx1" init code ... */
  Rx1_Init();
  (void)USB1_Init();
  /* ### FreeRTOS "FRTOS1" init code ... */
#if configSYSTICK_USE_LOW_POWER_TIMER
  /* enable clocking for low power timer, otherwise vPortStopTickTimer() will crash */
  SIM_PDD_SetClockGate(SIM_BASE_PTR, SIM_PDD_CLOCK_GATE_LPTMR0, PDD_ENABLE);
#endif
  vPortStopTickTimer(); /* tick timer shall not run until the RTOS scheduler is started */
}
Ejemplo n.º 7
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MK22FN1M0LH12)
**
**     Description :
**         Initializes beans and provides common register initialization. 
**         The method is called automatically as a part of the 
**         application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
      /* Initialization of the SIM module */
  /* PORTA_PCR4: ISF=0,MUX=7 */
  PORTA_PCR4 = (uint32_t)((PORTA_PCR4 & (uint32_t)~(uint32_t)(
                PORT_PCR_ISF_MASK
               )) | (uint32_t)(
                PORT_PCR_MUX(0x07)
               ));
        /* Initialization of the RCM module */
  /* RCM_RPFW: RSTFLTSEL=0 */
  RCM_RPFW &= (uint8_t)~(uint8_t)(RCM_RPFW_RSTFLTSEL(0x1F));
  /* RCM_RPFC: RSTFLTSS=0,RSTFLTSRW=0 */
  RCM_RPFC &= (uint8_t)~(uint8_t)(
               RCM_RPFC_RSTFLTSS_MASK |
               RCM_RPFC_RSTFLTSRW(0x03)
              );
  /* SIM_SCGC7: MPU=1 */
  SIM_SCGC7 |= SIM_SCGC7_MPU_MASK;
        /* Initialization of the MPU module */
  /* MPU_CESR: SPERR=0,VLD=0 */
  MPU_CESR &= (uint32_t)~(uint32_t)((MPU_CESR_SPERR(0x1F) | MPU_CESR_VLD_MASK));
      /* Initialization of the PMC module */
  /* PMC_LVDSC1: LVDACK=1,LVDIE=0,LVDRE=1,LVDV=0 */
  PMC_LVDSC1 = (uint8_t)((PMC_LVDSC1 & (uint8_t)~(uint8_t)(
                PMC_LVDSC1_LVDIE_MASK |
                PMC_LVDSC1_LVDV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC1_LVDACK_MASK |
                PMC_LVDSC1_LVDRE_MASK
               ));
  /* PMC_LVDSC2: LVWACK=1,LVWIE=0,LVWV=0 */
  PMC_LVDSC2 = (uint8_t)((PMC_LVDSC2 & (uint8_t)~(uint8_t)(
                PMC_LVDSC2_LVWIE_MASK |
                PMC_LVDSC2_LVWV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC2_LVWACK_MASK
               ));
  /* PMC_REGSC: BGEN=0,ACKISO=0,BGBE=0 */
  PMC_REGSC &= (uint8_t)~(uint8_t)(
                PMC_REGSC_BGEN_MASK |
                PMC_REGSC_ACKISO_MASK |
                PMC_REGSC_BGBE_MASK
               );
  /* SMC_PMPROT: ??=0,??=0,AVLP=0,??=0,ALLS=0,??=0,AVLLS=0,??=0 */
  SMC_PMPROT = 0x00U;                  /* Setup Power mode protection register */
  /* Common initialization of the CPU registers */
  /* NVICIP42: PRI42=0x80 */
  NVICIP42 = NVIC_IP_PRI42(0x80);
  /* NVICIP53: PRI53=0 */
  NVICIP53 = NVIC_IP_PRI53(0x00);
  /* NVICIP20: PRI20=0 */
  NVICIP20 = NVIC_IP_PRI20(0x00);
  /* NVICISER1: SETENA|=0x0400 */
  NVICISER1 |= NVIC_ISER_SETENA(0x0400);
  /* GPIOC_PDDR: PDD&=~0x0104 */
  GPIOC_PDDR &= (uint32_t)~(uint32_t)(GPIO_PDDR_PDD(0x0104));
  /* ### BitIO_LDD "BitIoLdd1" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd1_Init(NULL);
  /* ### BitIO_LDD "BitIoLdd2" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd2_Init(NULL);
  /* ### Init_FTM "FTM0" init code ... */
  FTM0_Init();


  /* ### SynchroMaster "SM1" init code ... */
  SM1_Init();
  /* ### BitIO_LDD "BitIoLdd4" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd4_Init(NULL);
  /* ### BitIO_LDD "BitIoLdd5" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd5_Init(NULL);
  /* ### ExtInt_LDD "ExtIntLdd1" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)ExtIntLdd1_Init(NULL);
  /* ### nRF24L01 "RF24" init code ... */
  /* ### CriticalSection "CS1" init code ... */
  /* ### Asynchro serial "AS1" init code ... */
  AS1_Init();
  /* ### KinetisSDK "KSDK1" init code ... */
  /* Write code here ... */
  /* ### Shell "mainShell" init code ... */
  mainShell_Init(); /* initialize shell */
  /* ### FreeRTOS "FRTOS1" init code ... */
#if configSYSTICK_USE_LOW_POWER_TIMER
  /* enable clocking for low power timer, otherwise vPortStopTickTimer() will crash */
  SIM_PDD_SetClockGate(SIM_BASE_PTR, SIM_PDD_CLOCK_GATE_LPTMR0, PDD_ENABLE);
#endif
  vPortStopTickTimer(); /* tick timer shall not run until the RTOS scheduler is started */
  /* ### FreeRTOS_Tasks "rtTasks" init code ... */
  rtTasks_CreateTasks();
  /* ### BitIO_LDD "BitIoLdd6" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd6_Init(NULL);
  /* ### BitIO_LDD "BitIoLdd7" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd7_Init(NULL);
  /* ### BitIO_LDD "BitIoLdd8" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd8_Init(NULL);
  /* ### GenericSWSPI "RFIDspi" init code ... */
  RFIDspi_Init();
  /* ### BitIO_LDD "BitIoLdd9" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd9_Init(NULL);
  /* ### ExtInt_LDD "ExtIntLdd2" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)ExtIntLdd2_Init(NULL);
  /* ### BitIO_LDD "BitIoLdd10" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd10_Init(NULL);
  /* ### BitIO_LDD "BitIoLdd11" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd11_Init(NULL);
  /* ### LEDbit "LED1" init code ... */
  LED1_Init(); /* initializes the driver */
  /* ### BitIO_LDD "BitIoLdd3" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd3_Init(NULL);
  /* ### LEDbit "LED2" init code ... */
  LED2_Init(); /* initializes the driver */
  /* ### BitIO_LDD "BitIoLdd12" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)BitIoLdd12_Init(NULL);
  /* ### LEDbit "LED3" init code ... */
  LED3_Init(); /* initializes the driver */
  /* ### Init_USB_OTG "USB0" init code ... */
  USB0_Init();


  /* ### RingBuffer "Tx1" init code ... */
  Tx1_Init();
  /* ### RingBuffer "Rx1" init code ... */
  Rx1_Init();
  (void)USB1_Init();
}
Ejemplo n.º 8
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (bean MC9S12GC16_80)
**
**     Description :
**         Initializes beans and provides common register initialization. 
**         The method is called automatically as a part of the 
**         application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  /* Int. priority initialization */
  /* HPRIO: PSEL7=1,PSEL6=1,PSEL5=0,PSEL4=1,PSEL3=0,PSEL2=0,PSEL1=1,??=0 */
  setReg8(HPRIO, 210);                 /* Set the highest interrupt priority to the ivVatd0 interrupt */ 
  /* Common initialization of the CPU registers */
  /* PORTA: BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=0,BIT0=0 */
  setReg8(PORTA, 0);                    
  /* PUCR: PUPEE=0,PUPAE=0 */
  clrReg8Bits(PUCR, 18);                
  /* DDRA: BIT7=1,BIT6=1,BIT5=1,BIT4=1,BIT3=1,BIT2=1,BIT1=1,BIT0=1 */
  setReg8(DDRA, 255);                   
  /* PORTB: BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=0,BIT0=0 */
  setReg8(PORTB, 0);                    
  /* DDRB: BIT7=1,BIT6=1,BIT5=1,BIT4=1,BIT3=1,BIT2=1,BIT1=1,BIT0=1 */
  setReg8(DDRB, 255);    
  /* PTM: PTM5=0,PTM4=0,PTM3=0,PTM2=0,PTM1=0,PTM0=0 */
  clrReg8Bits(PTM, 63);                 
  /* WOMM: WOMM5=0,WOMM4=0,WOMM3=0,WOMM2=0,WOMM1=0,WOMM0=0 */
  clrReg8Bits(WOMM, 63);                
  /* DDRM: DDRM5=1,DDRM4=1,DDRM3=1,DDRM2=1,DDRM1=1,DDRM0=1 */
  setReg8Bits(DDRM, 63);                
  /* PIEJ: PIEJ7=0,PIEJ6=0 */
  clrReg8Bits(PIEJ, 192);               
  /* PTJ: PTJ7=0,PTJ6=0 */
  clrReg8Bits(PTJ, 192);                
  /* PERJ: PERJ7=0,PERJ6=0 */
  clrReg8Bits(PERJ, 192);               
  /* DDRJ: DDRJ7=1,DDRJ6=1 */
  setReg8Bits(DDRJ, 192);               
  /* PTS: PTS2=0,PTS1=1 */
  clrSetReg8Bits(PTS, 4, 2);            
  /* WOMS: WOMS2=0 */
  clrReg8Bits(WOMS, 4);                 
  /* DDRS: DDRS2=1,DDRS1=1,DDRS0=0 */
  clrSetReg8Bits(DDRS, 1, 6);           
  /* TSCR1: TEN=0,TSWAI=1,TSFRZ=1,TFFCA=0 */
  clrSetReg8Bits(TSCR1, 144, 96);       
  /* PTT: PTT6=0,PTT5=0,PTT4=0,PTT3=0,PTT2=0,PTT1=0 */
  clrReg8Bits(PTT, 126);                
  /* PERT: PERT3=0,PERT2=0 */
  clrReg8Bits(PERT, 12);                
  /* DDRT: DDRT6=1,DDRT5=1,DDRT4=1,DDRT3=1,DDRT2=1,DDRT1=1 */
  //#ifndef RPM
   //setReg8Bits(DDRT, 126);
   //#else
  // setReg8Bits(DDRT, 114);
   //#endif                
  /* PEAR: RDWE=0 */
  clrReg8Bits(PEAR, 4);                 
  /* DDRE: BIT2=0 */
  clrReg8Bits(DDRE, 4);
   
  setReg8Bits(CRGINT, 18);       ///DDD clrReg8Bits(CRGINT, 18) BLOQUEO LA INT DEL RTI. PERMITO LA DEL LOCK Y LA DEL SELF CLOCK;         
  /* PACTL: CLK1=0,CLK0=0 */
  clrReg8Bits(PACTL, 12);               
  /* OC7M: OC7M0=0 */
  clrReg8Bits(OC7M, 1);                 
  /* TCTL2: OM1=0,OL1=0,OM0=0,OL0=0 */
  clrReg8Bits(TCTL2, 15);               
  /* TIE: C6I=0,C5I=0,C4I=0,C1I=0,C0I=1 */
  clrSetReg8Bits(TIE, 114, 1);          
  /* TIOS: IOS6=1,IOS5=1,IOS4=1,IOS1=1,IOS0=1 */
  setReg8Bits(TIOS, 255);               
  /* TTOV: TOV6=0,TOV5=0,TOV4=0,TOV1=0,TOV0=0 */
  clrReg8Bits(TTOV, 0);               
  /* TSCR2: TCRE=0,PR2=1,PR1=0,PR0=1 */
  clrSetReg8Bits(TSCR2, 10, 5);         
  /* TFLG1: C7F=1,C6F=1,C5F=1,C4F=1,C3F=1,C2F=1,C1F=1,C0F=1 */
  setReg8(TFLG1, 255);                  
  /* MODRR: ??=0,??=0,MODRR4=0,MODRR1=0 */
  clrReg8Bits(MODRR, 114);              
  /* TCTL1: OM6=0,OL6=0,OM5=0,OL5=0,OM4=0,OL4=0 */
  clrReg8Bits(TCTL1, 63);               
  /* PIEP: PIEP7=0,PIEP5=0,PIEP3=0,PIEP1=0 */
  clrReg8Bits(PIEP, 170);               
  /* PTP: PTP7=0,PTP5=0,PTP3=0,PTP1=0 */
  clrReg8Bits(PTP, 170);                
  /* PERP: PERP7=0,PERP5=0,PERP3=0,PERP1=0 */
  clrReg8Bits(PERP, 170);               
  /* DDRP: DDRP7=1,DDRP5=1,DDRP3=1,DDRP1=1 */
  setReg8Bits(DDRP, 170);               
  /* ATDDIEN: IEN3=1,IEN2=1 */
  setReg8Bits(ATDDIEN, 12);               
  /* VREGCTRL: LVIE=0 */
  clrReg8Bits(VREGCTRL, 2);             
  /* RDRIV: RDPE=0,RDPB=0,RDPA=0 */
  clrReg8Bits(RDRIV, 19);               
  /* RDRAD: RDRAD7=0,RDRAD6=0,RDRAD5=0,RDRAD4=0,RDRAD3=0,RDRAD2=0,RDRAD1=0,RDRAD0=0 */
  setReg8(RDRAD, 0);                    
  /* RDRJ: RDRJ7=0,RDRJ6=0 */
  clrReg8Bits(RDRJ, 192);               
  /* RDRM: RDRM5=0,RDRM4=0,RDRM3=0,RDRM2=0,RDRM1=0,RDRM0=0 */
  clrReg8Bits(RDRM, 63);                
  /* RDRP: RDRP7=0,RDRP6=0,RDRP5=0,RDRP4=0,RDRP3=0,RDRP2=0,RDRP1=0,RDRP0=0 */
  setReg8(RDRP, 0);                     
  /* RDRS: RDRS3=0,RDRS2=0,RDRS1=0,RDRS0=0 */
  clrReg8Bits(RDRS, 15);                
  /* RDRT: RDRT7=0,RDRT6=0,RDRT5=0,RDRT4=0,RDRT3=0,RDRT2=0,RDRT1=0,RDRT0=0 */
  setReg8(RDRT, 0);                     
  /* INTCR: IRQEN=0 */
  clrReg8Bits(INTCR, 64);               
  /* ### MC9S12GC16_80 "Cpu" init code ... */
  /* ### ByteIO "Display1" init code ... */
  /* ### BitsIO "bits5ULN" init code ... */
  /* ### BitsIO "bits2ULN" init code ... */
  /* ### BitIO "trx" init code ... */
  /* ### BitsIO "PTSL" init code ... */
  /* ### BitIO "PWSN" init code ... */
  /* ### InputPin "PUL" init code ... */
  /* ###  WatchDog "WDog1" init code ... */
  /* ### Asynchro serial "AS1" init code ... */
  
  
  
  AS1_Init();
  /* ### Init_ADC "ADC1" init code ... */
  #ifndef RPM
  
  ADC1_Init();
  #endif
  /* ### Init_FLASH "FLASH1" init code ... */

 
  
  FLASH1_Init();
  /* ### TimerInt "TI1" init code ... */
  
  TI1_Init();
  /* ### TimerOut "PWM" init code ... */


  PWM_Init();
  /* ### TimerOut "PWM4" init code ... */
  

  PWM4_Init();
  /* ### TimerOut "PWM5" init code ... */
 

  PWM5_Init();
  /* ### TimerOut "PWM6" init code ... */
 
  PWM6_Init();
  
  EI2C1_Init();
 
 
  
  /* TSCR1: TEN=1 */
  setReg8Bits(TSCR1, 128);              
  __EI();                              /* Enable interrupts */
}
Ejemplo n.º 9
0
/*										 
** ===================================================================
**     Function    : Comu_Init 
**     Description :
**         Inicialización de la comunicación
** ===================================================================
*/
void Comu_Init(void){
  AS1_Init();
  newAlloced(&comu_timer,&MethodTimer,(ulong)3,OnTimePass,NULL);
  Timer_Stop(&comu_timer);
}