Example #1
0
int main(void)
{
    InitLED();
    LCD_Initialize();

    RefreshLEDState(true, LED_MAX_BRIGHTNESS);
    Delay_ms(1000);
    RefreshLEDState(false, LED_MAX_BRIGHTNESS);

    while(true)
    {
        //LED_PORT->BSRR = LED_PIN;
        LCDFillScreen(0xFF, 0x00, 0x00);
        Delay_ms(1000);

        //LED_PORT->BRR = LED_PIN;
        LCDFillScreen(0x00, 0xFF, 0x00);
        Delay_ms(1000);

        //LED_PORT->BSRR = LED_PIN;
        LCDFillScreen(0x00, 0x00, 0xFF);
        Delay_ms(1000);

        //LED_PORT->BRR = LED_PIN;
        LCDFillScreen(0xFF, 0xFF, 0xFF);
        Delay_ms(1000);
    }
}
Example #2
0
//============================================================================= 
//函 数 名: GUI_Initialize() 
//功 能:	初始化GUI,包括初始化显示缓冲区,初始化LCM并清屏。
//入口参数: 无
//出口参数: 无
//返 回 值: 无
//============================================================================= 
void  GUI_Initialize(void)
{  
    LCD_Initialize();  // 初始化LCM模块工作模式,纯图形模式
    GUI_FillSCR(0x00); // 初始化缓冲区为0x00,并输出屏幕(清屏)
	
    GUIEnFont = En_8x16;
    GUITextMode = GUI_TEXTMODE_NORMAL;
    Char_XSIZE = En_8x16_XSIZE;
    Char_YSIZE = En_8x16_YSIZE;

}
Example #3
0
void HAL_Initialize()
{
    HAL_CONTINUATION::InitializeList();
    HAL_COMPLETION  ::InitializeList();

    Events_Initialize();

    CPU_GPIO_Initialize();

    CPU_SPI_Initialize();

    HAL_Time_Initialize();

    Time_Initialize();

    ENABLE_INTERRUPTS();

    BlockStorageList::Initialize();

    BlockStorage_AddDevices();

    BlockStorageList::InitializeDevices();

    FS_Initialize();

    FileSystemVolumeList::Initialize();

    FS_AddVolumes();

    FileSystemVolumeList::InitializeVolumes();



    CPU_InitializeCommunication();

    LCD_Initialize();

    I2C_Initialize();

    PalEvent_Initialize();

    Gesture_Initialize();

    Ink_Initialize();

    TimeService_Initialize();
    

/*
    other drivers init
*/
}
Example #4
0
int main(void)
{
  InitLED();
  RefreshLEDState(true, LED_MAX_BRIGHTNESS);
  LCD_Initialize();
  InitializeNRF24L01();

  ConfigureButtons(&leftButton, &rightButton, &upButton, &downButton);
  InitializeButtons();

  InitializeFileSystem();
  StartReceiveImages();
  return 0;
}
Example #5
0
//------------------------------------------------------------------------------
/// Initializes the LCD controller.
/// SMC are configured @ 96MHz for LCD.
/// \param pLcdBase   LCD base address.
//------------------------------------------------------------------------------
void LCDD_Initialize(void)
{
    const Pin pPins[] = {BOARD_LCD_PINS};
    AT91PS_HSMC4_CS pSMC = AT91C_BASE_HSMC4_CS2;
    unsigned int rMode;

    // Enable pins
    PIO_Configure(pPins, PIO_LISTSIZE(pPins));

    // Enable peripheral clock
    PMC_EnablePeripheral(AT91C_ID_HSMC4);

    // EBI SMC Configuration
    pSMC->HSMC4_SETUP = 0
                    | ((1 <<  0) & AT91C_HSMC4_NWE_SETUP)
                    | ((1 <<  8) & AT91C_HSMC4_NCS_WR_SETUP)
                    | ((9 << 16) & AT91C_HSMC4_NRD_SETUP)
                    | ((9 << 24) & AT91C_HSMC4_NCS_RD_SETUP)
                    ;

    pSMC->HSMC4_PULSE = 0
                    | (( 4 <<  0) & AT91C_HSMC4_NWE_PULSE)
                    | (( 4 <<  8) & AT91C_HSMC4_NCS_WR_PULSE)
                    | (( 36 << 16) & AT91C_HSMC4_NRD_PULSE)
                    | (( 36 << 24) & AT91C_HSMC4_NCS_RD_PULSE)
                    ;

    pSMC->HSMC4_CYCLE = 0
                    | ((10 <<  0) & AT91C_HSMC4_NWE_CYCLE)
                    | ((45 << 16) & AT91C_HSMC4_NRD_CYCLE)
                    ;
                 
    rMode = pSMC->HSMC4_MODE & ~(AT91C_HSMC4_DBW | AT91C_HSMC4_READ_MODE | AT91C_HSMC4_WRITE_MODE);
    pSMC->HSMC4_MODE = rMode
                 | (AT91C_HSMC4_READ_MODE)
                 | (AT91C_HSMC4_WRITE_MODE)
                 | (AT91C_HSMC4_DBW_WIDTH_SIXTEEN_BITS)
                 ;
                 
    // Initialize LCD controller (HX8347)
    LCD_Initialize((void *)BOARD_LCD_BASE);

    // Set LCD backlight
    LCDD_SetBacklight(25);
}
Example #6
0
/*******************************************************************************
 * º¯ÊýÃû(Function):	lpc1788_Lcd_Init
 * ²ÎÊý(Param):				ÎÞ 							
 * ·µ»ØÖµ(Return):		ÎÞ
 * ÃèÊö(Description):	LCD³õʼ»¯º¯Êý
 *******************************************************************************/
void lpc1788_Lcd_Init(void)
{
	LCD_Config_Type lcd_config;

	/* ژҕLCD࠘׆ */
	LCD_Enable (FALSE);
 
	/* ³õʼ»¯SDRAM */
	lpc1788_SDRAM_Init();
 lpc1788_SDRAM_Clean();


 	/* ÅäÖÃLCD²ÎÊý */
  lcd_config.big_endian_byte = 0;
  lcd_config.big_endian_pixel = 0;
  lcd_config.hConfig.hbp = LCD_H_BACK_PORCH;
  lcd_config.hConfig.hfp = LCD_H_FRONT_PORCH;
  lcd_config.hConfig.hsw = LCD_H_PULSE;
  lcd_config.hConfig.ppl = LCD_H_SIZE;
  lcd_config.vConfig.lpp = LCD_V_SIZE;
  lcd_config.vConfig.vbp = LCD_V_BACK_PORCH;
  lcd_config.vConfig.vfp = LCD_V_FRONT_PORCH;
  lcd_config.vConfig.vsw = LCD_V_PULSE;
  lcd_config.panel_clk   = LCD_PIX_CLK;
  lcd_config.polarity.active_high = 1;
  lcd_config.polarity.cpl = LCD_H_SIZE;
  lcd_config.polarity.invert_hsync = 1;
  lcd_config.polarity.invert_vsync = 1;
  lcd_config.polarity.invert_panel_clock = 0;
  lcd_config.lcd_panel_upper =  LCD_VRAM_BASE_ADDR_UPPER;
  lcd_config.lcd_panel_lower =  LCD_VRAM_BASE_ADDR_LOWER;
  lcd_config.lcd_bpp = LCD_BPP_16_565Mode;
  lcd_config.lcd_type = LCD_TFT;
	lcd_config.lcd_palette = NULL;
  lcd_config.lcd_bgr = FALSE;
	LCD_Initialize (&lcd_config);

//  LCD_SetImage(LCD_PANEL_UPPER, NULL);
//  LCD_SetImage(LCD_PANEL_LOWER, NULL);

	/* LCDʹÄÜ */
	LCD_Enable (TRUE);


}
Example #7
0
/**
 * \brief Initializes the LCD controller.
 * Configure SMC to access LCD controller at 64MHz MCK.
 */
extern void LCDD_Initialize( void )
{
    const Pin pPins[] = {BOARD_LCD_PINS};
    Smc *pSmc = SMC;

    /* Enable pins */
    PIO_Configure(pPins, PIO_LISTSIZE(pPins));

    /* Enable peripheral clock */
    PMC_EnablePeripheral( ID_SMC ) ;

    /* EBI SMC Configuration */
    pSmc->SMC_CS_NUMBER[1].SMC_SETUP = 0
                | ((2 <<  0) & SMC_SETUP1_NWE_SETUP)
                | ((2 <<  8) & SMC_SETUP1_NCS_WR_SETUP)
                | ((2 << 16) & SMC_SETUP1_NRD_SETUP)
                | ((2 << 24) & SMC_SETUP1_NCS_RD_SETUP)
                ;

    pSmc->SMC_CS_NUMBER[1].SMC_PULSE = 0
                | ((4  <<  0) & SMC_PULSE1_NWE_PULSE)
                | ((4  <<  8) & SMC_PULSE1_NCS_WR_PULSE)
                | ((10 << 16) & SMC_PULSE1_NRD_PULSE)
                | ((10 << 24) & SMC_PULSE1_NCS_RD_PULSE)
                ;

    pSmc->SMC_CS_NUMBER[1].SMC_CYCLE = 0
                | ((10 <<  0) & SMC_CYCLE1_NWE_CYCLE)
                | ((22 << 16) & SMC_CYCLE1_NRD_CYCLE)
                ;

    pSmc->SMC_CS_NUMBER[1].SMC_MODE = 0
                | (SMC_MODE1_READ_MODE)
                | (SMC_MODE1_WRITE_MODE)
                | (SMC_MODE1_DBW_8_BIT)
                ;

    /* Initialize LCD controller */
    LCD_Initialize() ;

    /* Set LCD backlight */
    LCDD_SetBacklight( 2 ) ;
}
Example #8
0
int main(void)
{
  volatile unsigned long int i;
  int temperatura;
  unsigned char temperaturaTekst[8]={" 0,0 C\0"};
	static const unsigned char stopienSymbol[8] = {0x06,0x09,0x09,0x06,0x00,0x00,0x00,0}; //symbol stopnia

  //konfiguracja systemu
  RCC_Config();   
  GPIO_Config(); 
  NVIC_Config();  
  SPI_Config(); 
  /*Tu nalezy umiescic ewentualne dalsze funkcje konfigurujace system*/
  GPIO_ResetBits(GPIOB, GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);		 

  LCD_Initialize();                                         //Inicjalizacja wysietlacza
  LCD_SetUserChar(1, 1, stopienSymbol);                     //Umiesc symbol stopnia pod kodem =1
  LCD_WriteCommand(HD44780_CLEAR);                          //Wyczysc wyswietlacz
  LCD_WriteText("Temp.:\0");        
  temperaturaTekst[5]=1;
  LCD_WriteTextXY(temperaturaTekst,7,0);                    //Wstaw do tekstu znak stopnia
  
  #define SPI_Mode_Slave_Mask ((unsigned short int)0xFEFB)  //Maska pozwalajaca wyzerowac bity trybu pracy wprost w rejestrzez SPIx->CR1
  while (1) {
    /*Tu nalezy umiescic glowny kod programu*/
    SPI1->CR1 |= SPI_Mode_Master;                           //Ustaw tryb master - wymusi to zmiane stanu NSS na niski
    while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); //Czekaj na dane
    temperatura = SPI_I2S_ReceiveData(SPI1);                //Odczytaj dane
    if ((temperatura&0x04)==0){                             //Sprawdz, czy zakonczono juz pierwszy pomiar po wlaczeniu ukladu TC77
      temperatura=0;                                        //Jesli nie, ustaw temp=0,  wprzeciwnym razie wynik bedzie bledny (>500stC)
    }
    temperatura = temperatura >> 3;                         //Usun 3 LSB
    SPI1->CR1 &= SPI_Mode_Slave_Mask;                       //Ustaw tryb slave - wymusi to zmiane stanu NSS na wysoki

		temperatura = (temperatura * 625)/100;                  //1 bit temperatury odpowiada 0,0625 stopnia
		sprintf((char *)temperaturaTekst, "%2d,%d C ", temperatura / 100, (temperatura % 100)/10 );
    temperaturaTekst[4]=1;                                  //Wstaw do tekstu znak stopnia
    LCD_WriteTextXY(temperaturaTekst,7,0);  
    for (i=0;i<4500000ul;i++); 
    GPIO_WriteBit(GPIOB, GPIO_Pin_15, (BitAction)(1-GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_15)));
  };
  return 0;
}
Example #9
0
void HAL_Initialize()
{
    HAL_CONTINUATION::InitializeList();
    HAL_COMPLETION  ::InitializeList();

    Events_Initialize();

    ENABLE_INTERRUPTS();
    
    CPU_InitializeCommunication();

    LCD_Initialize();

    I2C_Initialize();

/*
    other drivers init
*/

}
Example #10
0
/**
 * \brief Initializes the LCD controller.
 * Configure SMC to access LCD controller at 64MHz MCK.
 */
extern void LCDD_Initialize( void )
{
    const Pin pPins[] = {BOARD_LCD_PINS};
    Smc *pSmc = SMC;

    /* Enable pins */
    PIO_Configure(pPins, PIO_LISTSIZE(pPins));

    /* Enable peripheral clock */
    PMC_EnablePeripheral( ID_SMC ) ;

    /* EBI SMC Configuration */
    pSmc->SMC_CS_NUMBER[1].SMC_SETUP = SMC_SETUP_NWE_SETUP(2)
                                     | SMC_SETUP_NCS_WR_SETUP(2)
                                     | SMC_SETUP_NRD_SETUP(2)
                                     | SMC_SETUP_NCS_RD_SETUP(2);

    pSmc->SMC_CS_NUMBER[1].SMC_PULSE = SMC_PULSE_NWE_PULSE(4)
                                     | SMC_PULSE_NCS_WR_PULSE(4)
                                     | SMC_PULSE_NRD_PULSE(10)
                                     | SMC_PULSE_NCS_RD_PULSE(10);

    pSmc->SMC_CS_NUMBER[1].SMC_CYCLE = SMC_CYCLE_NWE_CYCLE(10)
                                     | SMC_CYCLE_NRD_CYCLE(22);

    pSmc->SMC_CS_NUMBER[1].SMC_MODE = SMC_MODE_READ_MODE
                                    | SMC_MODE_WRITE_MODE
                                    | SMC_MODE_DBW_8_BIT;

    /* Initialize LCD controller */
    LCD_Initialize() ;

    /* Initialize LCD controller */
    LCD_SetDisplayPortrait( 0 ) ;

    /* Set LCD backlight */
    LCDD_SetBacklight( 2 ) ;
}
int main(void)
{
char temp, i;
LCD_Initialize();
DDRB = 0b00000000;
PORTB = 0b00001111;

DDRA = 0xFF;
ADC_Init();
int value = 0;
int calculations = 0;

	char dzialanie = 0;

	
	int digit = 0;




	do{

	int digit  = getADC(0);

	char sw0 = PINB & 0b00000001;
	char sw1 = PINB & 0b00000010;
	if(sw0 != 0b00000001) {
		state++;
		_delay_ms(300);
	}
	

	  char str[15];


	  sprintf(str, "%15d", lastValue);
	LCD_GoTo(1,0);
	LCD_WriteText(str);


	switch(state){
		case 0:		
			if(sw1 != 0b00000010){
				setNewValue(mappingLogToLinear(digit, digitMap, 10));			
				_delay_ms(300);
			}
				sprintf(str, "%15d", mappingLogToLinear(digit, digitMap,10));
				LCD_GoTo(1,1);
				LCD_WriteText(str);	
			break;
		case 1:
			if(sw1 != 0b00000010){
				setSign(mappingLogToLinear(digit, signMap, 2));
				power = 0;				
				_delay_ms(300);
			}
				switch(mappingLogToLinear(digit, signMap,2)){
					case 0:
					LCD_GoTo(1,1);
					LCD_WriteText("-");
					break;
					case 1:
					LCD_GoTo(1,1);
					LCD_WriteText("+");
					break;
				}
			break;
		case 2:
			if(sw1 != 0b00000010){
				doCalculations(mappingLogToLinear(digit, expressionMap, 4));
				power = 0;
				newValue=0;
				state = 0;			
				_delay_ms(300);
			}
				
				switch(mappingLogToLinear(digit, expressionMap,4)){
					case 0:
					LCD_GoTo(1,1);
					LCD_WriteText("+");
					break;
					case 1:
					LCD_GoTo(1,1);
					LCD_WriteText("-");
					break;
					case 2:
					LCD_GoTo(1,1);
					LCD_WriteText("*");
					break;
					case 3:
					LCD_GoTo(1,1);
					LCD_WriteText("/");
					break;
				}
			break;
		}


/*
	char sw0 = PINB & 0b00000001;
	char sw1 = PINB & 0b00000010;
	char sw2 = PINB & 0b00000100;
	char sw3 = PINB & 0b00001000;

	if(sw0 != 0b00000001) value++;
	if(sw1 != 0b00000010) value--;

	if(sw2 != 0b00000100) {
		if(dzialanie == 0) calculations += value;
		if(dzialanie == 1) calculations -= value;
		if(dzialanie == 2) calculations /= value;
		if(dzialanie == 3) calculations *= value;
			value = 0;
	}


	if(sw3 != 0b00001000) {
		dzialanie++;
		dzialanie = dzialanie % 4;
	}




	  char str[15];


	  sprintf(str, "%15d", calculations);
	LCD_GoTo(1,0);
	LCD_WriteText(str);

	  sprintf(str, "%15d", value);
	LCD_GoTo(1,1);
	LCD_WriteText(str);
	_delay_ms(300);

	
	if(dzialanie == 0){
		LCD_GoTo(0,0);
		LCD_WriteText("+");
	}

	if(dzialanie == 1){
		LCD_GoTo(0,0);
		LCD_WriteText("-");
	}
	
	if(dzialanie == 2){
		LCD_GoTo(0,0);
		LCD_WriteText("/");
	}
	
	if(dzialanie == 3){
		LCD_GoTo(0,0);
		LCD_WriteText("*");
	}*/
	}while(1);

return 0;
}
Example #12
0
/*********************************************************************
 * Function:        void SYSTEM_Initialize( void )
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    Board is initialized for P2P usage
 *
 * Overview:        This function configures the board
 *
 * Note:            This routine needs to be called before the function
 *                  to initialize P2P stack or any other function that
 *                  operates on the stack
 ********************************************************************/
void SYSTEM_Initialize(void)
{

    // primary external oscillator
    OSCCON = 0x70;
    //OSCTUNEbits.PLLEN = 1;

    // set up the analogue port
    
    WDTCONbits.ADSHR = 1;
    ANCON0 = 0b11011111;        // all digital pin
    ANCON1 = 0xFF;
    WDTCONbits.ADSHR = 0;
    

    TRISA = 0xFF;
    TRISB = 0xFF;
    TRISC = 0xFF;
    TRISD = 0x00;

    LATA = 0;
    LATB = 0;
    LATC = 0;
    LATD = 0;

    // set I/O ports
    BUTTON_1_TRIS = 1;
    BUTTON_2_TRIS = 1;
    LED_1_TRIS = 0;
    LED_2_TRIS = 0;

    
    PHY_CS_TRIS = 0;
    PHY_CS = 1;
    PHY_RESETn_TRIS = 0;
    PHY_RESETn = 1;
    RF_INT_TRIS = 1;

    SDI_TRIS = 1;
    SDO_TRIS = 0;
    SCK_TRIS = 0;

    #if defined(HARDWARE_SPI)

        SSP1STAT = 0xC0;
        SSP1CON1 = 0x21;

    #else

        SPI_SDO = 0;
        SPI_SCK = 0;

    #endif
        
    INTCON2bits.INTEDG3 = 0;
        
    #if defined(ENABLE_NVM)

        EE_nCS_TRIS = 0;
        EE_nCS = 1;

    #endif

    INTCONbits.GIEH = 1;     
    RFIF = 0;
    RFIE = 1;

    LCD_Initialize();


}
Example #13
0
void SYSTEM_Initialize(void)
{

    // Make RB0 as Digital input
    AD1PCFGbits.PCFG2 = 1;

    // set I/O ports
    BUTTON_1_TRIS = 1;
    BUTTON_2_TRIS = 1;
    LED_1_TRIS = 0;
    LED_2_TRIS = 0;

   

    RF_INT_TRIS = 1;

    SDI_TRIS = 1;
    SDO_TRIS = 0;
    SCK_TRIS = 0;
    SPI_SDO = 0;
    SPI_SCK = 0;

    
    Data_nCS_TRIS = 0;
    Config_nCS_TRIS = 0;
    Data_nCS = 1;
    Config_nCS = 1;
    IRQ1_INT_TRIS = 1;
    IRQ0_INT_TRIS = 1;


    #if defined(HARDWARE_SPI)
        SPI1CON1 = 0b0000000100111110;
        SPI1STAT = 0x8000;

        SPI2CON1 = 0b0000000100111110;
        SPI2STAT = 0x8000;
    #endif

   
    INTCON2bits.INT1EP = 0;
    INTCON2bits.INT2EP = 0;

    IPC7bits.INT2IP2 = 1;
    IPC7bits.INT2IP1 = 0;
    IPC7bits.INT2IP0 = 0;

    IPC5bits.INT1IP2 = 1;
    IPC5bits.INT1IP1 = 0;
    IPC5bits.INT1IP0 = 0;
        
    

    // Make RB0 as Digital input
    AD1PCFGbits.PCFG2 = 1;

    #if defined(ENABLE_NVM)
        EE_nCS_TRIS = 0;
        EE_nCS = 1;
    #endif

    
    PHY_IRQ1 = 0;
    PHY_IRQ0 = 0;
    PHY_RESETn_TRIS = 1;
 



    LCD_Initialize();

}
Example #14
0
void SYSTEM_Initialize(void)
{

    // primary internal oscillator
    OSCCON = 0x7B;
    WDTCONbits.SWDTEN = 0;

    INTCON = 0;

    EECON2 = 0x55;
    EECON2 = 0xAA;
    PPSCONbits.IOLOCK = 0;

    #if defined(MRF49XA) || defined(MRF24XA)
        RPINR3 = 6;
    #endif

    #if defined(MRF24J40)
        RPINR1 = 4;
    #endif

    #if defined(MRF89XA)
        RPINR3 = 6;
    #endif

    #if !defined(SENSOR_PORT_UART)
        // use LCD
        RPINR21 = 19;           //Mapping SDI2 to RD2
        RPOR23 = 9;             //Mapping SDO2 to RD6
        RPOR21 = 10;            //Mapping SCK2 to RD4
    #endif

    #if defined(SENSOR_PORT_UART)
        // use UART
        RPINR16 = 19;
        RPOR17 = 5;
    #endif

    EECON2 = 0x55;
    EECON2 = 0xAA;
    PPSCONbits.IOLOCK = 1;


    ANCON0 = 0xFF;
    ANCON1 = 0x3F;
    INTCON2bits.RBPU = 0;

    TRISA = 0xFF;
    TRISB = 0xFF;
    TRISC = 0xFF;
    TRISD = 0xFF;
    TRISE = 0xFF;

    LATA = 0;
    LATB = 0;
    //LATC = 0;
    LATD = 0;
    LATE = 0;

    TRISDbits.TRISD2 = 0;
    LATDbits.LATD2 = 1;
    TRISCbits.TRISC6 = 0;
    LATCbits.LATC6 = 0;

    // set I/O ports
    BUTTON_1_TRIS = 1;
    BUTTON_2_TRIS = 1;
    LED_1_TRIS = 0;
    LED_2_TRIS = 0;

    #if defined(MRF24J40) || defined(MRF49XA) || defined(MRF24XA)
        PHY_CS_TRIS = 0;
        PHY_CS = 1;
        PHY_RESETn_TRIS = 0;
        PHY_RESETn = 1;
        RF_INT_TRIS = 1;
    #endif
    #if defined(MRF89XA)
        PHY_RESETn_TRIS = 1;
        IRQ1_INT_TRIS = 1;
        IRQ0_INT_TRIS = 1;
        #if defined(USE_IRQ0_AS_INTERRUPT)
            PHY_IRQ0_En = 1;
            PHY_IRQ0 = 0;
            //Enable the effective INT edge
        #endif
    #endif


    SDI_TRIS = 1;
    SDO_TRIS = 0;
    SCK_TRIS = 0;


    #if defined(HARDWARE_SPI)
        SSP1STAT = 0xC0;
        SSP1CON1 = 0x21;
    #else
        SPI_SDO = 0;
        SPI_SCK = 0;
    #endif

    #if defined(MRF49XA)
        nFSEL_TRIS = 0;
        FINT_TRIS = 1;
        nFSEL = 1;          // nFSEL inactive

        // enable INT effective edge
        INTCON2bits.INTEDG3 = 0;
    #endif

    #if defined(MRF24XA)
        // enable INT effective edge
        INTCON2bits.INTEDG3 = 0;
    #endif

    #if defined(MRF24J40)
        PHY_WAKE_TRIS = 0;
        PHY_WAKE = 1;

        // enable INT effective edge
        INTCON2bits.INTEDG1 = 0;
    #endif

    #if defined(MRF89XA)
        Data_nCS_TRIS = 0;
        Config_nCS_TRIS = 0;
        Data_nCS = 1;
        Config_nCS = 1;
        INTCON2bits.INTEDG3 = 1;
    #endif
        RF_EEnCS_TRIS = 0;
        RF_EEnCS = 1;
    #if defined(ENABLE_NVM)

        EE_nCS_TRIS = 0;
        EE_nCS = 1;

    #endif

    INTCONbits.GIEH = 1;
    #if defined(MRF24J40) || defined(MRF49XA) || defined(MRF24XA)
        RFIF = 0;
        RFIE = 1;
    #endif

    #if defined(SENSOR_PORT_LCD)
        LCD_Initialize();
    #endif

}
Example #15
0
void SYSTEM_Initialize(void)
{

    // primary internal oscillator
    OSCCON = 0x7B;
    WDTCONbits.SWDTEN = 0;

    INTCON = 0;

    //Peripheral pin select definitions
    EECON2 = 0x55;
    EECON2 = 0xAA;
    PPSCONbits.IOLOCK = 0;

    
    RPINR1 = 4;

    #if !defined(SENSOR_PORT_UART)
        // use LCD
        RPINR21 = 19;           //Mapping SDI2 to RD2
        RPOR23 = 9;             //Mapping SDO2 to RD6
        RPOR21 = 10;            //Mapping SCK2 to RD4
    #endif

    #if defined(SENSOR_PORT_UART)
        // use UART
        RPINR16 = 19;
        RPOR17 = 5;
    #endif

    EECON2 = 0x55;
    EECON2 = 0xAA;
    PPSCONbits.IOLOCK = 1;

    //All digital pins, defaults
    ANCON0 = 0xFF;
    ANCON1 = 0x3F;
    INTCON2bits.RBPU = 0;

    TRISA = 0xFF;
    TRISB = 0xFF;
    TRISC = 0xFF;
    TRISD = 0xFF;
    TRISE = 0xFF;

    LATA = 0;
    LATB = 0;
    //LATC = 0;
    LATD = 0;
    LATE = 0;

    //Push button definitions
    BUTTON_1_TRIS = 1;
    BUTTON_2_TRIS = 1;
    LED_1_TRIS = 0;
    LED_2_TRIS = 0;

    //RF CS, RESET, INT pin definitions
    PHY_CS_TRIS = 0;
    PHY_CS = 1;
    PHY_RESETn_TRIS = 0;
    PHY_RESETn = 1;
    RF_INT_TRIS = 1;
    
    

    //SPI Definitions
    SDI_TRIS = 1;
    SDO_TRIS = 0;
    SCK_TRIS = 0;
    #if defined(HARDWARE_SPI)
        SSP1STAT = 0xC0;
        SSP1CON1 = 0x21;
    #else
        SPI_SDO = 0;
        SPI_SCK = 0;
    #endif
   //Wake pin definitions
    PHY_WAKE_TRIS = 0;
    PHY_WAKE = 1;

    // enable INT effective edge
    INTCON2bits.INTEDG1 = 0;
    //Enable MAC Address EEPROM
    RF_EEnCS_TRIS = 0;
    RF_EEnCS = 1;

    
    //Enable Interrupts
    INTCONbits.GIEH = 1;
    RFIF = 0;
    RFIE = 1;
    #if defined(ENABLE_NVM)
        EE_nCS_TRIS = 0;
        EE_nCS = 1;
    #endif
    #if defined(SENSOR_PORT_LCD)
        LCD_Initialize();
    #endif

}