コード例 #1
0
ファイル: Application.c プロジェクト: 3ben1189/mcuoneclipse
void APP_Run(void) {
  int i;
  uint32_t val = 0;
  unsigned char buf[16];

  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
      WAIT1_Waitms(10);
    }
    LED2_Off(); LED1_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           )
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"val: ");
      UTIL1_strcatNum32u(buf, sizeof(buf), val);
      UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n");
      (void)CDC1_SendString(buf);
      val++;
    } else {
      WAIT1_Waitms(10);
    }
  }
}
コード例 #2
0
ファイル: Application.c プロジェクト: 210221030/mcuoneclipse
void APP_HandleEvent(byte event) {
  switch(event) {
    case EVNT1_INIT:
      LED1_On(); WAIT1_Waitms(200); 
      LED2_On(); WAIT1_Waitms(200); 
      LED3_On(); WAIT1_Waitms(200); 
      LED4_On(); WAIT1_Waitms(200);
      LED1_Off(); LED2_Off(); LED3_Off(); LED4_Off();
      break;
    case EVNT1_SW1_PRESSED:
      LED1_On(); WAIT1_Waitms(200); LED1_Off();
      break;
    case EVNT1_SW2_PRESSED:
      LED2_On(); WAIT1_Waitms(200); LED2_Off();
      break;
    case EVNT1_SW3_PRESSED:
      LED3_On(); WAIT1_Waitms(200); LED3_Off();
      break;
    case EVNT1_SW4_PRESSED:
      LED4_On(); WAIT1_Waitms(200); LED4_Off();
      break;
    case EVNT1_SW1_LONG_PRESSED:
      LED1_On(); WAIT1_Waitms(500); LED1_Off();
      break;
    case EVNT1_SW2_LONG_PRESSED:
      LED2_On(); WAIT1_Waitms(500); LED2_Off();
      break;
    case EVNT1_SW3_LONG_PRESSED:
      LED3_On(); WAIT1_Waitms(500); LED3_Off();
      break;
    case EVNT1_SW4_LONG_PRESSED:
      LED4_On(); WAIT1_Waitms(500); LED4_Off();
      break;
  } /* switch */
}
コード例 #3
0
void APP_Start(void) {
  PL_Init(); /* platform initialization */
  //TEST_Test();
  EVNT_SetEvent(EVNT_INIT); /* set initial event */
#if PL_HAS_RTOS
  if (FRTOS1_xTaskCreate(AppTask, (signed portCHAR *)"App", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) {
    for(;;){} /* error */
  }
  RTOS_Run();
#else
  APP_Loop();
#endif
#if 0
  for(;;) {
#if PL_HAS_MEALY
    MEALY_Step();
#else
    LED1_On();
    WAIT1_Waitms(300);
    LED1_Off();
    LED2_On();
    WAIT1_Waitms(300);
    LED2_Off();
    LED3_On();
    WAIT1_Waitms(300);
    LED3_Off();
#endif
  }
#endif
  /* just in case we leave the main application loop */
  PL_Deinit();
}
コード例 #4
0
ファイル: LED.c プロジェクト: tbsimmen/INTRO_Robotfiles
/*!
 * \brief LED test routine.
 * This routine tests if:
 * - we can turn the LEDs properly on and off
 * - if we can negate them
 * - if we can set an LED value
 * - if we can get the LED value
 * If the test fails, the program will hanging in an endless loop
 */
void LED_Test(void) {
  bool isOn = TRUE;

  LED1_On();
  LED2_On();
  LED3_On();

  LED1_Off();
  LED2_Off();
  LED3_Off();

  LED1_Neg();
  LED2_Neg();
  LED3_Neg();

  LED1_On();
/*
 if (!LED1_Get()) {
   LED3_Off();
  }

  LED1_Off();
  if (LED1_Get()) {
    for(;;){}; /* error
  }
  LED1_Put(isOn);
  if (!LED1_Get()) {
    for(;;){}; /* error
  }
  */
}
コード例 #5
0
static void CDC_Run(void) {
  int i;
  
  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
     // WAIT1_Waitms(1); /* just give back some CPU time. S08JM60 does not allow much spare time here! */
    }
    LED1_Off(); LED2_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1 
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           ) 
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      (void)CDC1_SendString((unsigned char*)"\r\n");
    } else {
      //WAIT1_Waitms(5);
    }
  }
}
コード例 #6
0
static void CDC_Run(void) {
  int i;

  SendStr((unsigned char*)"Hello World to Kinetis SCI3!\r\n");
  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
     // WAIT1_Waitms(1); /* just give back some CPU time. */
      SendStr((unsigned char*)"waiting to enumerate...\r\n");
    }
    LED1_Off(); LED2_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           )
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      (void)CDC1_SendString((unsigned char*)"\r\n");
      SendStr((unsigned char*)"echo to SCI3: ");
      SendStr(in_buffer);
      SendStr((unsigned char*)"\r\n");
    } else {
     // WAIT1_Waitms(5);
    }
  }
}
コード例 #7
0
ファイル: Application.c プロジェクト: nitsu121/mcuoneclipse
void APP_Run(void) {
  LED1_On();
  LED1_Off();
  LED2_On();
  LED2_Off();
  LED3_On();
  LED3_Off();
#if PL_HAS_SHELL
  SHELL_Init();
#endif
#if PL_HAS_ESC
  ESC_Init();
#endif
  if (FRTOS1_xTaskCreate(
      AppTask,  /* pointer to the task */
      "Main", /* task name for kernel awareness debugging */
      configMINIMAL_STACK_SIZE, /* task stack size */
      (void*)NULL, /* optional task startup argument */
      tskIDLE_PRIORITY,  /* initial priority */
      (xTaskHandle*)NULL /* optional task handle to create */
    ) != pdPASS)
  {
    for(;;){} /* error! probably out of memory */
  }
  FRTOS1_vTaskStartScheduler();
  for(;;) {}
}
コード例 #8
0
ファイル: main.c プロジェクト: CanoAdrian/mcuoneclipse
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* 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 */
  LED1_On();
  WAIT1_Waitms(100);
  LED1_Off();

  LED2_On();
  WAIT1_Waitms(100);
  LED2_Off();

  LED3_On();
  WAIT1_Waitms(100);
  LED3_Off();

  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!!! ***/
コード例 #9
0
ファイル: LED2.c プロジェクト: jeffyoon/mcuoneclipse
/*
** ===================================================================
**     Method      :  Init (component LED)
**
**     Description :
**         Performs the LED driver initialization.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void LED2_Init(void)
{
#if MCUC1_CONFIG_SDK_VERSION_USED != MCUC1_CONFIG_SDK_PROCESSOR_EXPERT
  LEDpin2_Init();
#endif
  LED2_Off();
}
コード例 #10
0
static void CDC_Run(void) {
  int i;
  
  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
      WAIT1_Waitms(10);
    }
    LED1_Off(); LED2_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1 
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           ) 
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      (void)CDC1_SendString((unsigned char*)"\r\n");
    } else {
      WAIT1_Waitms(10);
    }
  }
}
コード例 #11
0
ファイル: LED2.c プロジェクト: jeffyoon/mcuoneclipse
/*
** ===================================================================
**     Method      :  SetRatio16 (component LED)
**
**     Description :
**         Method to specify the duty cycle. If using a PWM pin, this
**         means the duty cycle is set. For On/off pins, values smaller
**         0x7FFF means off, while values greater means on.
**     Parameters  :
**         NAME            - DESCRIPTION
**         ratio           - Ratio value, where 0 means 'off' and
**                           0xffff means 'on'
**     Returns     : Nothing
** ===================================================================
*/
void LED2_SetRatio16(uint16_t ratio)
{
  /* on/off LED: binary on or off */
  if (ratio<(0xffff/2)) {
    LED2_Off();
  } else {
    LED2_On();
  }
}
コード例 #12
0
/* User includes (#include below this line is not maintained by Processor Expert) */
static portTASK_FUNCTION(LedTask, pvParameters) {
  (void)pvParameters; /* parameter not used */
  LED1_Off();
  LED2_Off();
  LED3_Off();
  for(;;) {
    LED1_Neg();
    FRTOS1_vTaskDelay(100/portTICK_RATE_MS);
  }
}
コード例 #13
0
ファイル: main.c プロジェクト: Athuli7/Microchip
/****************************************************************************
  Function:
    void SetLEDs(BYTE setting)

  Summary:
    change the LED settings of the boards

  Description:
    change the LED settings of the boards

  Precondition:
    None

  Parameters:
    BYTE setting - bitmap for desired LED setting (1 = On, 0 = Off)
        bit 0 = LED 0
        bit 1 = LED 1
        bit 2 = LED 2
        ...
        bit 7 = LED 7

  Return Values:
    None

  Remarks:
    None
  ***************************************************************************/
static void SetLEDs(BYTE setting)
{
    if((setting & 0x01) == 0x01) { LED0_On(); } else { LED0_Off(); }
    if((setting & 0x02) == 0x02) { LED1_On(); } else { LED1_Off(); }
    if((setting & 0x04) == 0x04) { LED2_On(); } else { LED2_Off(); }
    if((setting & 0x08) == 0x08) { LED3_On(); } else { LED3_Off(); }
    if((setting & 0x10) == 0x10) { LED4_On(); } else { LED4_Off(); }
    if((setting & 0x20) == 0x20) { LED5_On(); } else { LED5_Off(); }
    if((setting & 0x40) == 0x40) { LED6_On(); } else { LED6_Off(); }
    if((setting & 0x80) == 0x80) { LED7_On(); } else { LED7_Off(); }
}
コード例 #14
0
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* 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.                    ***/

#if PL_HAS_SD_CARD
  /* SD card detection: PTE6 with pull-down! */
  PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN);
  PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);
#endif
#if PL_HAS_KEYS
  /* SW3: PTA4 */
  PORT_PDD_SetPinPullSelect(PORTA_BASE_PTR, 4, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTA_BASE_PTR, 4, PORT_PDD_PULL_ENABLE);
  /* SW2: PTC6 */
  PORT_PDD_SetPinPullSelect(PORTC_BASE_PTR, 6, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTC_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);
#endif
#if PL_HAS_BLUETOOTH
  /* pull up Rx pin (PTC14) for Bluetooth module */
  PORT_PDD_SetPinPullSelect(PORTC_BASE_PTR, 14, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTC_BASE_PTR, 14, PORT_PDD_PULL_ENABLE);
#endif
  LED1_On();
  WAIT1_Waitms(50);
  LED1_Off();
  WAIT1_Waitms(50);
  LED2_On();
  WAIT1_Waitms(50);
  LED2_Off();
  WAIT1_Waitms(50);
  LED3_On();
  WAIT1_Waitms(50);
  LED3_Off();
  WAIT1_Waitms(50);
  APP_Start();

  /*** 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!!! ***/
コード例 #15
0
ファイル: LED.c プロジェクト: cknuesel/INTRO_Maze_it
void LED_Deinit(void) {
#if PL_CONFIG_NOF_LED>=1
  LED1_Off();
#endif
#if PL_CONFIG_NOF_LED>=2
  LED2_Off();
#endif
#if PL_CONFIG_NOF_LED>=3
  LED3_Off();
#endif
#if PL_CONFIG_NOF_LED>=4
  #error "only 3 LEDs supported"
#endif
}
コード例 #16
0
ファイル: Application.c プロジェクト: dansog56/mcuoneclipse
void APP_Run(void) {
  int16_t x,y,z;
  uint8_t res;
  #define ACCEL_VAL  2000

  res = FX1_Enable(); /* enable accelerometer (just in case) */
  if (res!=ERR_OK) {
    Err();
  }
  if (FAT1_Init()!=ERR_OK) {
    Err();
  }
  if (FAT1_mount(0, &fileSystemObject) != FR_OK) { /* mount file system */
    Err();
  }
  for(;;) {
    //LED1_Neg();
    x = FX1_GetX();
    y = FX1_GetY();
    z = FX1_GetZ();
    if (x>ACCEL_VAL || x<-ACCEL_VAL) {
      LED1_On();
      LED2_Off();
      LED3_Off();
    } else if (y>ACCEL_VAL || y<-ACCEL_VAL) {
      LED1_Off();
      LED2_On();
      LED3_Off();
    } else if (z>ACCEL_VAL || z<-ACCEL_VAL) {
      LED1_Off();
      LED2_Off();
      LED3_On();
    }
    LogToFile(x, y, z);
    WAIT1_Waitms(1000);
  }
}
コード例 #17
0
ファイル: LED.c プロジェクト: tbsimmen/INTRO_Robotfiles
void LED_Init(void){
	LED1_Init();
	LED2_Init();
	LED3_Init();

	/*turn all LEDS OFF per default */
#if PL_NOF_LEDS>=1
LED1_Off();
#endif
#if PL_NOF_LEDS>=2
LED2_Off();
#endif
#if PL_NOF_LEDS>=3
LED3_Off();
#endif
}
コード例 #18
0
ファイル: RNet_App.c プロジェクト: c-kel/Assorted
static uint8_t RNETA_HandleRxMessage(RAPP_MSG_Type type, uint8_t size, uint8_t *data, RNWK_ShortAddrType srcAddr, bool *handled, RPHY_PacketDesc *packet) {
  (void)srcAddr;
  (void)packet;
  switch(type) {
    case RAPP_MSG_TYPE_PING: /* <type><size><data */
      *handled = TRUE;
      /* to be defined: do something with the ping, e.g blink a LED */
      LED2_On(); /* green LED blink */
      FRTOS1_vTaskDelay(20/portTICK_RATE_MS);
      LED2_Off();
      return ERR_OK;
    default:
      break;
  } /* switch */
  return ERR_OK;
}
コード例 #19
0
void APP_Run(void) {
#if configUSE_TRACE_HOOKS
  if (RTOSTRC1_uiTraceStart()==0) {
    for(;;){} /* error starting trace recorder. Not setup for enough queues/tasks/etc? */
  }
#endif

#if PL_HAS_SD_CARD
  /* SD card detection: PTB16 with pull-down! */
  PORT_PDD_SetPinPullSelect(PORTB_BASE_PTR, 16, PORT_PDD_PULL_DOWN);
  PORT_PDD_SetPinPullEnable(PORTB_BASE_PTR, 16, PORT_PDD_PULL_ENABLE);
#endif
#if PL_HAS_PUSH_BUTTONS
  /* SW2: PTC1 */
  PORT_PDD_SetPinPullSelect(PORTC_BASE_PTR, 1, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTC_BASE_PTR, 1, PORT_PDD_PULL_ENABLE);
  /* SW3: PTB17 */
  PORT_PDD_SetPinPullSelect(PORTB_BASE_PTR, 17, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTB_BASE_PTR, 17, PORT_PDD_PULL_ENABLE);
#endif

  LED1_On();
  LED1_Off();
  LED2_On();
  LED2_Off();
  LED3_On();
  LED3_Off();
#if PL_HAS_SHELL
  SHELL_Init();
#endif
#if PL_HAS_ESC
  ESC_Init();
#endif
  if (FRTOS1_xTaskCreate(
      AppTask,  /* pointer to the task */
      "Main", /* task name for kernel awareness debugging */
      configMINIMAL_STACK_SIZE, /* task stack size */
      (void*)NULL, /* optional task startup argument */
      tskIDLE_PRIORITY,  /* initial priority */
      (xTaskHandle*)NULL /* optional task handle to create */
    ) != pdPASS)
  {
    for(;;){} /* error! probably out of memory */
  }
  FRTOS1_vTaskStartScheduler();
  for(;;) {}
}
コード例 #20
0
ファイル: ProcessorExpert.c プロジェクト: Joteyo/mcuoneclipse
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* 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.                    ***/
  LED2_On();
  WAIT1_Waitms(1000);
  LED2_Off();
  
#if PL_HAS_LOW_POWER
  LP_Init();
#endif
#if PL_HAS_RTOS
  if (FRTOS1_xTaskCreate(BlinkTask, "Blink", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL) != pdPASS) {
    for(;;){} /* error */
  }
#endif
#if PL_HAS_SHELL
  SHELL_Init();
#endif
#if PL_HAS_RTOS
  PEX_RTOS_START();
#endif
  for(;;) {
    LP_EnterPowerMode(LP_WAIT);
    LED1_On();
    WAIT1_Waitms(20);
    LED1_Off();
  }

  /* For example: for(;;) { } */

  /*** 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!!! ***/
コード例 #21
0
void APP_Run(void) {
  uint8_t res=ERR_OK;
  uint8_t xyz[3];
  
  LED1_On();
  LED2_On();
  LED3_On();
  res = MMA8451_Init();
  while (res==ERR_OK) {
    res = MMA8451_GetRawXYZ(&xyz[0]);
    LED1_Put(xyz[0]>50);
    LED2_Put(xyz[1]>50);
    LED3_Put(xyz[2]>50);
  }
  LED1_Off();
  LED2_Off();
  LED3_Off();
}
コード例 #22
0
ファイル: Shell.c プロジェクト: ADeadCat/mcuoneclipse
static portTASK_FUNCTION(USBTask, pvParameters) {
  static uint8_t cdc_buffer[USB1_DATA_BUFF_SIZE];
  uint8_t cntr = 0;

  (void)pvParameters; /* unused */
  USB1_Init(); /* have Init of USB1 component disabled during Startup! */
  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      FRTOS1_vTaskDelay(50/portTICK_RATE_MS);
      LED2_Off();
    }
    cntr++;
    if ((cntr%16)==0) {
      LED2_Neg();
    }
    FRTOS1_vTaskDelay(20/portTICK_RATE_MS);
  }
}
コード例 #23
0
static void CDC_Run(void) {
  int i, cnt = 0;
  uint32_t val = 0;
  unsigned char buf[16];

  (void)CDC1_SendString((unsigned char*)"Hello world from the KL25Z with USB CDC\r\n");
  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
      WAIT1_Waitms(10);
      cnt++;
      if (cnt==100) {
        LED3_Neg();
        cnt = 0;
      }
    }
    LED1_Off(); LED2_Neg(); LED3_Off();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           )
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"val: ");
      UTIL1_strcatNum32u(buf, sizeof(buf), val);
      UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n");
      (void)CDC1_SendString(buf);
      val++;
    } else {
      WAIT1_Waitms(10);
      cnt++;
      if ((cnt%1024)==0) { /* from time to time, write some text */
        (void)CDC1_SendString((unsigned char*)"Type some text and it will echo.\r\n");
      }
    }
  }
}
コード例 #24
0
ファイル: LED.c プロジェクト: cknuesel/INTRO_Maze_it
void LED_Test(void) {
#if PL_CONFIG_NOF_LED>=1
	LED1_On();
	WAIT1_Waitms(500);
	LED1_Off();
#endif
#if PL_CONFIG_NOF_LED>=2
	LED2_On();
	WAIT1_Waitms(500);
	LED2_Off();
#endif
#if PL_CONFIG_NOF_LED>=3
	LED3_On();
	WAIT1_Waitms(500);
	LED3_Off();
#endif
#if PL_CONFIG_NOF_LED>=4
	#error "only 3 LED ;)"
#endif
}
コード例 #25
0
ファイル: Application.c プロジェクト: 210221030/mcuoneclipse
void APP_HandleEvent(byte event) {
  switch(event) {
    case EVNT1_INIT:
      LED1_On(); LED2_On(); LED3_On(); LED4_On();
      WAIT1_Waitms(500);
      LED1_Off(); LED2_Off(); LED3_Off(); LED4_Off();
      break;
    case EVNT1_BTN1_PRESSED:
#if HAS_SOUND
      RTOS_StartSounder(300);
#endif
      LED4_Neg();
      SHELL_SendStr("SW1 pressed!\r\n");
      break;
    case EVNT1_BTN2_PRESSED:
#if HAS_SOUND
      RTOS_StartSounder(500);
#endif
      LED5_Neg();
      SHELL_SendStr("SW2 pressed!\r\n");
      break;
    case EVNT1_BTN3_PRESSED:
#if HAS_SOUND
      RTOS_StartSounder(700);
#endif
      LED7_Neg();
      SHELL_SendStr("SW3 pressed!\r\n");
      break;
    case EVNT1_BTN4_PRESSED:
#if HAS_SOUND
      RTOS_StartSounder(900);
#endif
      LED8_Neg();
      SHELL_SendStr("SW4 pressed!\r\n");
      break;
    default:
      break;
  } /* switch */
}
コード例 #26
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.                    ***/

  LED1_Neg();
  WAIT1_Waitms(100);
  LED2_Neg();
  WAIT1_Waitms(100);
  LED3_Neg();
  WAIT1_Waitms(100);
  LED4_Neg();
  WAIT1_Waitms(100);
  LED1_Off(); LED2_Off(); LED3_Off(); LED4_Off();
  CDC_Run();

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** 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!!! ***/
コード例 #27
0
ファイル: main.c プロジェクト: Wassili-Hense/Vers3
void SystemTick(void)
{
    SystemTickCnt++;

#ifdef LED1_On
    if(LED_Mask & 2)
    {
        LED_Mask &= 0xFD;
        LED1_On();
    }
    else
        LED1_Off();
#endif  //  LED1_On

#ifdef LED2_On
    if(LED_Mask & 4)
    {
        LED_Mask &= 0xFB;
        LED2_On();
    }
    else
        LED2_Off();
#endif  //  LED2_On
}
コード例 #28
0
ファイル: Application.c プロジェクト: tbmathis/SUMO
/*! \brief Handles the Events */
static void APP_EventHandler(EVNT_Handle event) {
	uint8_t err;
  switch(event) {
    case EVNT_INIT:
      LED1_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED1_Off();
      LED2_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED2_Off();
      LED3_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED3_Off();
      break;
    case EVENT_LED_HEARTBEAT:
      LED2_Neg();
      break;
    case EVNT_SW1_PRESSED:
      lastKeyPressed = 1;
      LED1_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED1_Off();
      //EVNT_SetEvent(EVNT_REF_START_STOP_CALIBRATION);
#if PL_HAS_FIGHT_MODE
      FIGHT_SetState(FIGHT_STATE_COUNTDOWN);
      break;
#endif

#if PL_HAS_LINE_SENSOR
    case EVNT_REF_START_STOP_CALIBRATION: //Create event again, because the event is handled in the "Reflectance.c" directly.
    	if(!EVNT_EventIsSet(EVNT_REF_START_STOP_CALIBRATION))
    	{
    		EVNT_SetEvent(EVNT_REF_START_STOP_CALIBRATION);
    	}

      break;
#endif

#if PL_IS_FRDM
    case EVNT_SW2_PRESSED:
      lastKeyPressed = 2;
      LED1_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED1_Off();
      break;
    case EVNT_SW3_PRESSED:
      lastKeyPressed = 3;
      LED1_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED1_Off();
      break;
    case EVNT_SW4_PRESSED:
      lastKeyPressed = 4;
      LED1_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED1_Off();
      break;
    case EVNT_SW5_PRESSED:
      lastKeyPressed = 5;
      LED1_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED1_Off();
      break;
    case EVNT_SW6_PRESSED:
      lastKeyPressed = 6;
      LED1_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED1_Off();
      break;
    case EVNT_SW7_PRESSED:
      lastKeyPressed = 7;
      LED1_On();
      vTaskDelay(50/portTICK_RATE_MS);
      LED1_Off();
      break;
#endif
    default:
      break;
  }
}
コード例 #29
0
void LED_Init(void) {
  /* all LED's off by default */
  LED1_Off();
  LED2_Off();
  LED3_Off();
}
コード例 #30
0
ファイル: Application.c プロジェクト: ADeadCat/mcuoneclipse
void APP_Run(void) {
  int cnt=0; /* counter to slow down LED blinking */
  uint8_t res;
  int16_t xyz[3];
#if 0
  res = MMA1_Init();
  if (res!=ERR_OK) {
    Err();
  }
  res = MMA1_SetFastMode(FALSE);
  if (res!=ERR_OK) {
    Err();
  }
  res = MMA1_Enable(); /* enable accelerometer */
  if (res!=ERR_OK) {
    Err();
  }
#endif
  for(;;) {
    WAIT1_Waitms(10);
#if 0
    /* implement 'air-mouse' movement */
    xyz[0] = MMA1_GetX();
    xyz[1] = MMA1_GetY();
    xyz[3] = MMA1_GetZ();
    /* y axis */
    if (xyz[1]>AIR_THRESHOLD) {
      (void)HIDK2_Move(0, 2); /* moving the cursor left */
    } else if (xyz[1]<-AIR_THRESHOLD) {
      (void)HIDK2_Move(0, -2); /* moving the cursor right */
    }
    /* x axis */
    if (xyz[0]>AIR_THRESHOLD) {
      (void)HIDK2_Move(-2, 0); /* moving the cursor up */
    } else if (xyz[0]<-AIR_THRESHOLD) {
      (void)HIDK2_Move(2, 0); /* moving the cursor down */
    }
#endif
    cnt++;
    if (HIDM1_App_Task()==ERR_BUSOFF) {
      if ((cnt%128)==0) { /* just slow down blinking */
        LED1_Neg(); /* red LED */
        LED2_Off();
      }
    } else {
      if ((cnt%128)==0) { /* just slow down blinking */
        LED1_Off();
        LED2_Neg(); /* green LED */
      }
      if (SW2_GetVal()==0) { /* button pressed */
        WAIT1_Waitms(100); /* wait for debouncing */
        if (SW2_GetVal()==0) { /* still pressed */
          //(void)HIDK2_Send(0, 8, 8); /* raw move message */
          
          //(void)HIDK2_Send(HIDK2_MOUSE_LEFT, 0, 0); /* send left mouse button */
          //(void)HIDK2_Send(0, 0, 0); /* send release button message */
          
          //(void)HIDK2_Move(-8, 0); /* moving the cursor up */
          
          //HIDK2_Click(HIDK2_MOUSE_LEFT); /* left mouse click */
          
          HIDM1_Click(HIDM1_MOUSE_RIGHT); /* right mouse click */
        }
        while(SW2_GetVal()==0) {} /* wait until button is released */
      }
      if (SW3_GetVal()==0) { /* button pressed */
        WAIT1_Waitms(100); /* wait for debouncing */
        if (SW3_GetVal()==0) { /* still pressed */
          HIDM1_Click(HIDM1_MOUSE_LEFT); /* left mouse click */
        }
        while(SW3_GetVal()==0) {} /* wait until button is released */
      }
    }
  }
}