Пример #1
0
static void radio_bus_init()
{
    status = RF_IDLE;

    SPI2_Init_Advanced( _SPI_FPCLK_DIV64, _SPI_MASTER | _SPI_8_BIT
                        | _SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION
                        | _SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE
                        | _SPI_SSI_1, &_GPIO_MODULE_SPI2_PB13_14_15 );

    GPIO_Digital_Output( &GPIOG_BASE, _GPIO_PINMASK_12 | _GPIO_PINMASK_9 );
    GPIO_Digital_Input( &GPIOG_BASE, _GPIO_PINMASK_10 );  // Set input for IRQ

    // Enable clock for alternate pin functions
    RCC_APB2ENR |= ( 1 << RCC_APB2ENR );  //SYSCFGEN_bit = 1;

    // Map external interrupt on PG10
    SYSCFG_EXTICR3 |= ( 1 << EXTI81 ) | ( 1 << EXTI82 );

    EXTI_RTSR &= ~( 1 << TR10 );     // Set interrupt on Rising edge (none)

    EXTI_FTSR |= ( 1 << TR10 );      // Set Interrupt on Falling edge (PG10)

    EXTI_IMR |= ( 1 << MR10 );       // Set mask

    NVIC_IntEnable( IVT_INT_EXTI15_10 );   // Enable External interrupt

    bus_initialized = true;
    // Note: Radio - By default all IRQ sources are enabled.
}
Пример #2
0
void Conf_puertos(void)
{
 GPIO_Digital_Output(&GPIOB_BASE,_GPIO_PINMASK_10|_GPIO_PINMASK_11|_GPIO_PINMASK_12);
 GPIO_Digital_Output(&GPIOB_BASE,_GPIO_PINMASK_13|_GPIO_PINMASK_14|_GPIO_PINMASK_15);
 GPIO_Digital_Input(&GPIOA_BASE,_GPIO_PINMASK_0);
 GPIO_Digital_Output(&GPIOC_BASE,_GPIO_PINMASK_8);
}
Пример #3
0
void Initialize() {
  short int i = 0;
  // variable initialization
  LQI = 0;
  RSSI2 = 0;
  SEQ_NUMBER = 0x23;
  lost_data = 0;
  address_RX_FIFO = 0x300;
  address_TX_normal_FIFO = 0;

  for (i = 0; i < 2; i++) {
    ADDRESS_short_1[i] = 1;
    ADDRESS_short_2[i] = 2;
    PAN_ID_1[i] = 3;
    PAN_ID_2[i] = 3;
  }

  for (i = 0; i < 8; i++) {
    ADDRESS_long_1[i] = 1;
    ADDRESS_long_2[i] = 2;
  }

  // Set Chip Select pin as Output
  GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_13);
  GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_10);
  GPIO_Digital_Output(&GPIOC_BASE, _GPIO_PINMASK_2);

  // Set PD0 and PD1 as digital input
  GPIO_Digital_Input(&GPIOD_BASE, _GPIO_PINMASK_0);


  Delay_ms(5);

  // SPI config
  SPI3_Init_Advanced(_SPI_FPCLK_DIV4, _SPI_MASTER  | _SPI_8_BIT |
                     _SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION |
                     _SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE | _SPI_SSI_1,
                     &_GPIO_MODULE_SPI3_PC10_11_12);
  TFT_BLED = 1;                             // Turn on TFT Backlight

  TFT_Init(320, 240);                       // Initialize TFT display
  TFT_Fill_Screen(CL_WHITE);                // Clear Screen

  pin_reset();                              // Activate reset from pin
  software_reset();                         // Activate software reset
  RF_reset();                               // RF reset
  set_WAKE_from_pin();                      // Set wake from pin

  set_long_address(ADDRESS_long_2);         // Set long address
  set_short_address(ADDRESS_short_2);       // Set short address
  set_PAN_ID(PAN_ID_2);                     // Set PAN_ID

  init_ZIGBEE_nonbeacon();                  // Initialize ZigBee module
  nonbeacon_PAN_coordinator_device();
  set_TX_power(31);                         // Set max TX power
  set_frame_format_filter(1);               // 1 all frames, 3 data frame only
  set_reception_mode(1);                    // 1 normal mode

  pin_wake();                               // Wake from pin
}
void UI_Setup()
{
  GPIO_Config(&GPIO_PORTA, 0b00001000, _GPIO_DIR_OUTPUT, _GPIO_CFG_DIGITAL_ENABLE | _GPIO_CFG_DRIVE_8mA, 0); // Init back light GPIO
  TFT_BACKLIGHT = 0;
  // We need to Unlock PR7 before we can use it as GPIO (MCU specific)
  GPIO_Unlock(_GPIO_COMMIT_PIN_B7);
  GPIO_Digital_Input(&GPIO_PORTB, _GPIO_PINMASK_0 | _GPIO_PINMASK_7);    // Set Up and Left as digital input
  GPIO_Digital_Input(&GPIO_PORTE, _GPIO_PINMASK_4 | _GPIO_PINMASK_5);    // Set Right and Down as digital input
  GPIO_Digital_Input(&GPIO_PORTH, _GPIO_PINMASK_2);                      // Set Center as digital input
  Delay_100ms();
  TFT_Init(320, 240);
  
  TFT_Fill_Screen(0);
  InitializeObjects();
  display_width = LoadingScreen.Width;
  display_height = LoadingScreen.Height;
  UI_LoadingScreen("Fetching IP address");

  TFT_BACKLIGHT = 1;
}
Пример #5
0
void InitModules(void)
{
    GPIO_Digital_Input( &PTB_PDOR, _GPIO_PINMASK_13 );

    OLED_Init();
    OLED_SetFont( guiFont_Tahoma_8_Regular, OLED_COLOR_WHITE, 0 );
//    OLED_DrawImage( &hexiwearLogo_bmp, 0, 0 );
    OLED_DrawImage( &fire_off_bmp, 0, 0 );

    ADC0_Init();
}
Пример #6
0
/* FUNCTIONS
 ******************************************************************************/
void system_init()
{
    GPIO_Digital_Input( &GPIO_PORT_24_31, _GPIO_PINMASK_4 );                    /* Button pin */
    GPIO_Digital_Output( &GPIO_PORT_08_15, _GPIO_PINMASK_1 );                   /* STB pin */
    Delay_ms( 200 );
                                                                                /* DBG UART */
    UART1_Init( 115200 );
    Delay_ms( 200 );
                                                                                /* MODULE UART */
    UART2_Init( 115200 );
    Delay_ms( 200 );

    UART1_Write_Text( "System Initialized\r\n" );
}
void system_setup( uint8_t width, uint8_t height, panel_size_t panel_size )
{
    GPIO_Digital_Output( &GPIOD_BASE, _GPIO_PINMASK_13); // Set Chip Select pin as output
    GPIO_Digital_Output( &GPIOC_BASE, _GPIO_PINMASK_2 ); // Set Reset pin to output
    GPIO_Digital_Input( &GPIOD_BASE, _GPIO_PINMASK_10);  // Set Ready to input

    // Initialize SPI
    SPI3_Init_Advanced(_SPI_FPCLK_DIV2, _SPI_MASTER | _SPI_8_BIT |
                       _SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION |
                       _SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_DISABLE | _SPI_SSI_1,
                       &_GPIO_MODULE_SPI3_PC10_11_12);

    MATRIXRGB_RST = 0;        //Reset slave ( toggle )
    Delay_ms(20);
    MATRIXRGB_RST = 1;
    Delay_ms(200);

    matrixrgb_init( width, height, panel_size );
    Delay_ms(200);

}
Пример #8
0
/*
 * System initialization
 *
 * This function initializes the system
 */
static int system_init()
{
    DisableInterrupts();
    GPIO_Digital_Input( &PTB_PDOR, _GPIO_PINMASK_13 );

    I2C0_Init_Advanced(400000, &_GPIO_Module_I2C0_PD8_9);
    Delay_ms( 100 );
    
    // Initialize APDS-9960 (configure I2C and initial values)
    ir_gesture_init( APDS9960_I2C_ADDR );
    ir_gesture_enable_gesture_sensor( true );
    
    // Initialize screen
    OLED_Init();
    OLED_DrawImage( irgesture_bmp, 0, 0 );
    OLED_SetFont( guiFont_Tahoma_8_Regular, OLED_COLOR_WHITE, 0 );

    PORTB_PCR13bits.IRQC = 0xB;
    NVIC_IntEnable( IVT_INT_PORTB );
    EnableInterrupts();

    return 0;
}
void main() 
{

int index=0;
int b=15;
unsigned long* output[4]={&GPIOA_ODR,&GPIOB_ODR,&GPIOC_ODR,&GPIOD_ODR};
GPIO_Digital_Input(&GPIOE_IDR,_GPIO_PINMASK_11|_GPIO_PINMASK_12);
GPIO_Digital_Output(&GPIOA_ODR,_GPIO_PINMASK_ALL);
GPIO_Digital_Output(&GPIOB_ODR,_GPIO_PINMASK_ALL);
GPIO_Digital_Output(&GPIOC_ODR,_GPIO_PINMASK_ALL);
GPIO_Digital_Output(&GPIOD_ODR,_GPIO_PINMASK_ALL);
GPIO_Digital_Input(&GPIOD_IDR,_GPIO_PINMASK_2|_GPIO_PINMASK_4);
GPIO_Digital_Input(&GPIOA_IDR,_GPIO_PINMASK_6);
GPIO_Digital_Input(&GPIOB_IDR,_GPIO_PINMASK_5);


while(1)
{
  if(Button(&GPIOE_IDR, 11, 1, 1))
  {
      *output[index]=0;
      b--;
      if(b==-1)
      {
        index++;
        index&=3;
        if(index==0)b=15;
        else if(index==1)b=12;
        else if(index==2)b=13;
        else if(index==3)b=15;
      }
      *output[index]|=1<<b;
      while(Button(&GPIOE_IDR, 11, 1, 1)) {}
  }
  else if(Button(&GPIOE_IDR, 12, 1, 1))
  {
      *output[index]=0;
      b++;
      if(index==0 && b==16){b=0;index=3;}
      else if(index==1&&b==13){b=0;index=0;}
      else if(index==2&&b==14){b=0;index=1;}
      else if(index==3&&b==16){b=0;index=2;}
      *output[index]|=1<<b;
       while(Button(&GPIOE_IDR, 12, 1, 1)) {}
  }
  else if(Button(&GPIOD_IDR, 4, 1, 1))
  {
       while(Button(&GPIOD_IDR, 4, 1, 1)) {}
       if(b==3||b==7||b==11||b==15)
       {
         blank(output[index],b);
       }
       else
       {
              *output[index]=0;
              b++;
              *output[index]|=(1<<b);
              
       }
  }
   else if(Button(&GPIOB_IDR, 5, 1, 1))
  {
       while(Button(&GPIOB_IDR, 5, 1, 1)) {}
       if(b==0||b==4||b==8||b==12)
       {
          blank(output[index],b);
       }
       else
       {
              *output[index]=0;
              b--;
              *output[index]|=(1<<b);

       }
  }
   else if(Button(&GPIOD_IDR, 2, 1, 1))
  {
       while(Button(&GPIOD_IDR, 2, 1, 1)) {}
       if(b<12)
       {

              *output[index]=0;
              b=b+4;
              *output[index]|=(1<<b);
       }
       else
       {      if(index==0)
               {
                 blank(output[index],b);
               }
               else
               {
                   *output[index]=0;
                    b=b-12;
                    index--;
                    *output[index]|=(1<<b);
               }
       }
  }
  
   else if(Button(&GPIOA_IDR, 6, 1, 1))
  {
       while(Button(&GPIOA_IDR, 6, 1, 1)) {}
       if(b>3)
       {
              *output[index]=0;
              b=b-4;
              *output[index]|=(1<<b);
       }
       else
       {      if(index==3)
               {
                  blank(output[index],b);
               }
               else
               {
                   *output[index]=0;
                    b=b+12;
                    index++;
                    *output[index]|=(1<<b);
               }
       }
  }
}


}