コード例 #1
0
ファイル: common.c プロジェクト: cpantel/ciaa
/*==================[definiciones de funciones externas]=====================*/
void printError(void) 
{
   static uint8_t OSErrorGetServiceIdTxt[][25]={
      "Undefined",
      "ActivateTask",
      "TerminateTask",
      "ChainTask",
      "Schedule",
      "GetTAskID",
      "GetTaskState",
      "DisableAllInterrupts",
      "EnableAllInterrupts",
      "SuspendAllInterrupts",
      "ResumeAllInterrupts",
      "SuspendOSInterrupts",
      "ResumeOSInterrupts",
      "GetResource",
      "ReleaseResource",
      "SetEvent",
      "ClearEvent",
      "GetEvent",
      "WaitEvent",
      "GetAlarmBase",
      "GetAlarm",
      "SetRelAlarm",
      "SetAbsAlarm",
      "CancelAlarm",
      "GetACtiveApplicationMode",
      "StartOS",
      "ShutdownOS"
   };

   static uint8_t OSErrorGetRetTxt[][13]={
      "E_OK",
      "E_OS_ACCESS",
      "E_OS_CALLEVEL",
      "E_OS_ID"
      "E_OS_LIMIT",
      "E_OS_NOFUNC",
      "E_OS_RESOURCE",
      "E_OS_STATE",
      "E_OS_VALUE"
   };


   uartWriteString(UART_USB, "\n-----------------------------------\n");
   uartWriteString(UART_USB, "Service:\n");
   uartWriteByte(UART_USB, ( OSErrorGetServiceId() + 48 ) );

   uartWriteString(UART_USB, " = ");
   uartWriteString(UART_USB, ( OSErrorGetServiceIdTxt[OSErrorGetServiceId()]) );
   uartWriteString(UART_USB, " ---> ");
   uartWriteByte(UART_USB, ( OSErrorGetRet() + 48 ) );
   uartWriteString(UART_USB, " = ");
   uartWriteString(UART_USB, ( OSErrorGetRetTxt[OSErrorGetRet()] ) );

   uartWriteString(UART_USB, "\n-----------------------------------\n");
}
コード例 #2
0
/*********************************************************************
 * @fn      performPeriodicTask
 *
 * @brief   Perform a periodic application task. This function gets
 *          called every five seconds as a result of the SBP_PERIODIC_EVT
 *          OSAL event. In this example, the value of the third
 *          characteristic in the SimpleGATTProfile service is retrieved
 *          from the profile, and then copied into the value of the
 *          the fourth characteristic.
 *
 * @param   none
 *
 * @return  none
 */
static void performPeriodicTask( void )
{
  
#if defined UART_debug
  uartWriteString("simple in house\r\n");
#endif

}
コード例 #3
0
ファイル: main.c プロジェクト: elsuizo/sAPI
/* Enviar fecha y hora en formato "DD/MM/YYYY, HH:MM:SS" */
void showDateAndTime( RTC_t * rtc ){
   /* Conversion de entero a ascii con base decimal */
   itoa( (int) (rtc->mday), (char*)uartBuff, 10 ); /* 10 significa decimal */
   /* Envio el dia */
   if( (rtc->mday)<10 ) 
      uartWriteByte( UART_USB, '0' );
   uartWriteString( UART_USB, uartBuff );
   uartWriteByte( UART_USB, '/' );

   /* Conversion de entero a ascii con base decimal */
   itoa( (int) (rtc->month), (char*)uartBuff, 10 ); /* 10 significa decimal */
   /* Envio el mes */
   if( (rtc->month)<10 ) 
      uartWriteByte( UART_USB, '0' );
   uartWriteString( UART_USB, uartBuff );
   uartWriteByte( UART_USB, '/' );

   /* Conversion de entero a ascii con base decimal */
   itoa( (int) (rtc->year), (char*)uartBuff, 10 ); /* 10 significa decimal */
   /* Envio el año */
   if( (rtc->year)<10 ) 
      uartWriteByte( UART_USB, '0' );
   uartWriteString( UART_USB, uartBuff );
   
   
   uartWriteString( UART_USB, (uint8_t*) ", ");
   

   /* Conversion de entero a ascii con base decimal */
   itoa( (int) (rtc->hour), (char*)uartBuff, 10 ); /* 10 significa decimal */
   /* Envio la hora */
   if( (rtc->hour)<10 ) 
      uartWriteByte( UART_USB, '0' );
   uartWriteString( UART_USB, uartBuff );
   uartWriteByte( UART_USB, ':' );

   /* Conversion de entero a ascii con base decimal */
   itoa( (int) (rtc->min), (char*)uartBuff, 10 ); /* 10 significa decimal */
   /* Envio los minutos */
  // uartBuff[2] = 0;    /* NULL */
   if( (rtc->min)<10 ) 
      uartWriteByte( UART_USB, '0' );
   uartWriteString( UART_USB, uartBuff );
   uartWriteByte( UART_USB, ':' );

   /* Conversion de entero a ascii con base decimal */
   itoa( (int) (rtc->sec), (char*)uartBuff, 10 ); /* 10 significa decimal */
   /* Envio los segundos */
   if( (rtc->sec)<10 ) 
      uartWriteByte( UART_USB, '0' );
   uartWriteString( UART_USB, uartBuff );
   
   
   /* Envio un 'enter' */
   uartWriteString( UART_USB, (uint8_t*) "\r\n");
}
コード例 #4
0
static void performPeriodicTask( void ){


    int16 pXVal=0;
    int16 pYVal=0;
    int16 pZVal=0;
  
  accReadAcc( &pXVal, &pYVal, &pZVal);
  
  
  //uartWriteU16(0x2412);
 
  uartWriteString("X: ");
  uartWriteU16(pXVal);
  uartWriteString("\n\r");
  uartWriteString("Y: ");
  uartWriteU16(pYVal);
  uartWriteString("\n\r");
  uartWriteString("Z: ");
  uartWriteU16(pZVal);
  uartWriteString("\n\r");
 uartWriteString("---------------\n\r");
  




}
コード例 #5
0
void Task2_Init(uint8 task_id) {



	TaskID=task_id;

	#if defined UART_debug
		uartWriteString("-------T2---init--task---\n\r");
	#endif
	osal_set_event( TaskID, T2_start );



}
コード例 #6
0
ファイル: main.c プロジェクト: cpantel/ciaa
void UartMonitorInit() {
   uartConfig( UART_USB, 115200 );
   uartWriteString( UART_USB, "ready osek ej21libs build 20\n");
}
コード例 #7
0
ファイル: main.c プロジェクト: cpantel/ciaa
void ErrorHook(void)
{
   printError();
   uartWriteString( UART_USB, "ShutdownOS\n");
   ShutdownOS(0);
}
コード例 #8
0
ファイル: main.c プロジェクト: cpantel/ciaa
void ShowElapsedTimeInit() {
   uartConfig( UART_USB, 115200 );
   uartWriteString( UART_USB, "ready osek v3\n");
}
コード例 #9
0
ファイル: main.c プロジェクト: elsuizo/sAPI
/* FUNCION PRINCIPAL, PUNTO DE ENTRADA AL PROGRAMA LUEGO DE RESET. */
int main(void){

   /* ------------- INICIALIZACIONES ------------- */

   /* Inicializar la placa */
   boardConfig();

   /* Inicializar el conteo de Ticks con resolución de 1ms, sin tickHook */
   tickConfig( 1, 0 );

   /* Inicializar DigitalIO */
   digitalConfig( 0, ENABLE_DIGITAL_IO );

   /* Configuración de pines de entrada para Teclas de la CIAA-NXP */
   digitalConfig( TEC1, INPUT );
   digitalConfig( TEC2, INPUT );
   digitalConfig( TEC3, INPUT );
   digitalConfig( TEC4, INPUT );

   /* Configuración de pines de salida para Leds de la CIAA-NXP */
   digitalConfig( LEDR, OUTPUT );
   digitalConfig( LEDG, OUTPUT );
   digitalConfig( LEDB, OUTPUT );
   digitalConfig( LED1, OUTPUT );
   digitalConfig( LED2, OUTPUT );
   digitalConfig( LED3, OUTPUT );

   /* Inicializar UART_USB a 115200 baudios */
   uartConfig( UART_USB, 115200 );
   
   uint8_t dato  = 0;
   uint8_t dato1 = 1;
   uint8_t dato2 = 78;
   int32_t dato3 = 1234;

   /* Buffer */
   static uint8_t uartBuff[10];
   
   uartWriteByte( UART_USB, 'h' - 32 );   /* Envía 'H' */
   uartWriteByte( UART_USB, 'A' + 32 );   /* Envía 'a' */

   /* Enviar un Enter */
   uartWriteByte( UART_USB, '\r' ); /* Envía '\r', retorno de carro */
   uartWriteByte( UART_USB, '\n' ); /* Envía '\n', nueva línea      */

   uartWriteByte( UART_USB, dato1 + 48 ); /* Envía '1' */
   uartWriteByte( UART_USB, ' ' );        /* Envía ' ' */
   uartWriteByte( UART_USB, '1' );        /* Envía '1' */
   uartWriteByte( UART_USB, 32 );         /* Envía ' ' */

   /* Convertir un número entero de 2 dígitos ASCII y enviar */
   uartWriteByte( UART_USB, (dato2/10) + 48 ); /* Envía '7' */
   uartWriteByte( UART_USB, (dato2%10) + 48 ); /* Envía '8' */

   uartWriteString( UART_USB, "\r\n" ); /* Enviar un Enter */

   uartWriteByte( UART_USB, 'H' );  /* Envía 'H' */
   uartWriteByte( UART_USB, 'o' );  /* Envía 'o' */
   uartWriteByte( UART_USB, 'l' );  /* Envía 'l' */
   uartWriteByte( UART_USB, 'a' );  /* Envía 'a' */
   uartWriteByte( UART_USB, '\r' ); /* Envía '\r', retorno de carro */
   uartWriteByte( UART_USB, '\n' ); /* Envía '\n', nueva línea      */
   
   uartWriteString( UART_USB, "Chau\r\n" ); /* Envía "Chau\r\n" */
   
   uint8_t miTexto[] = "Hola de nuevo\r\n";

   uartWriteString( UART_USB, miTexto ); /* Envía "Hola de nuevo\r\n" */
   
   miTexto[0] = 'h';
   uartWriteString( UART_USB, miTexto ); /* Envía "hola de nuevo\r\n" */

   /* Conversión de muestra entera a ascii con base decimal usando itoa() */
   itoa( dato3, uartBuff, 10 ); /* base 10 significa decimal */
   uartWriteString( UART_USB, uartBuff );

   uartWriteString( UART_USB, "\r\n" ); /* Enviar un Enter */

   /* ------------- REPETIR POR SIEMPRE ------------- */
   while(1) {

      /* Recibir byte de la UART_USB y guardarlo en la variable dato */
      dato = uartReadByte( UART_USB );
      
      /* Si el byte recibido es distinto de 0 (caracter NULL) se reenvía 
         a la UART_USB realizando un eco de lo que llega */
      if( dato ){
         uartWriteByte( UART_USB, dato );
      }

   }

   /* NO DEBE LLEGAR NUNCA AQUI, debido a que a este programa no es llamado
      por ningun S.O. */
   return 0 ;
}
コード例 #10
0
static void peripheralStateNotificationCB( gaprole_States_t newState )
{
  switch ( newState )
  {
    case GAPROLE_STARTED:
      {

      #if defined UART_debug  
        uartWriteString("In sim BLE start\r\n");
      #endif

      }
      break;

    case GAPROLE_ADVERTISING:
      {
        #if defined UART_debug
          uartWriteString("In sim BLE adv\r\n");
        #endif
      }
      break;

    case GAPROLE_CONNECTED:
      {
        #if (defined HAL_LCD) && (HAL_LCD == TRUE)
          HalLcdWriteString( "Connected",  HAL_LCD_LINE_3 );
        #endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
      }
      break;

    case GAPROLE_WAITING:
      {
        #if (defined HAL_LCD) && (HAL_LCD == TRUE)
          HalLcdWriteString( "Disconnected",  HAL_LCD_LINE_3 );
        #endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
      }
      break;

    case GAPROLE_WAITING_AFTER_TIMEOUT:
      {
        #if (defined HAL_LCD) && (HAL_LCD == TRUE)
          HalLcdWriteString( "Timed Out",  HAL_LCD_LINE_3 );
        #endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
      }
      break;

    case GAPROLE_ERROR:
      {
        #if (defined HAL_LCD) && (HAL_LCD == TRUE)
          HalLcdWriteString( "Error",  HAL_LCD_LINE_3 );
        #endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
      }
      break;

    default:
      {
        #if (defined HAL_LCD) && (HAL_LCD == TRUE)
          HalLcdWriteString( "",  HAL_LCD_LINE_3 );
        #endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
      }
      break;

  }

  gapProfileState = newState;



}
コード例 #11
0
/*********************************************************************
 * @fn      SimpleBLEPeripheral_Init
 *
 * @brief   Initialization function for the Simple BLE Peripheral App Task.
 *          This is called during initialization and should contain
 *          any application specific initialization (ie. hardware
 *          initialization/setup, table initialization, power up
 *          notificaiton ... ).
 *
 * @param   task_id - the ID assigned by OSAL.  This ID should be
 *                    used to send messages and set timers.
 *
 * @return  none
 */
void SimpleBLEPeripheral_Init( uint8 task_id )
{
  simpleBLEPeripheral_TaskID = task_id;

  #if defined UART_debug
    uartWriteString("sample task init\r\n");
  #endif
  // Setup the GAP Peripheral Role Profile
  {

   

    //starts advertising upon initialization
    uint8 initial_advertising_enable = TRUE;

    // By setting this to zero, the device will go into the waiting state after
    // being discoverable for 30.72 second, and will not being advertising again
    // until the enabler is set back to TRUE

    /*
    uint16 gapRole_AdvertOffTime = 0;

    uint8 enable_update_request = DEFAULT_ENABLE_UPDATE_REQUEST;
    uint16 desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
    uint16 desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
    uint16 desired_slave_latency = DEFAULT_DESIRED_SLAVE_LATENCY;
    uint16 desired_conn_timeout = DEFAULT_DESIRED_CONN_TIMEOUT;
*/
    // Set the GAP Role Parameters


    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
   // GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );

   // GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData );
   // GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );

   // GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enable_update_request );
   // GAPRole_SetParameter( GAPROLE_MIN_CONN_INTERVAL, sizeof( uint16 ), &desired_min_interval );
   // GAPRole_SetParameter( GAPROLE_MAX_CONN_INTERVAL, sizeof( uint16 ), &desired_max_interval );
   // GAPRole_SetParameter( GAPROLE_SLAVE_LATENCY, sizeof( uint16 ), &desired_slave_latency );
   // GAPRole_SetParameter( GAPROLE_TIMEOUT_MULTIPLIER, sizeof( uint16 ), &desired_conn_timeout );
  }

  // Set the GAP Characteristics
 // GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName );

  // Set advertising interval
  {
   // uint16 advInt = DEFAULT_ADVERTISING_INTERVAL;

   // GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, advInt );
   // GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, advInt );
   // GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, advInt );
   // GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, advInt );
  }

  // Setup the GAP Bond Manager
 /* {
    uint32 passkey = 123456; // passkey "000000"
    uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
    uint8 mitm = TRUE;
    uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
    uint8 bonding = TRUE;
    GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );
    GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );
    GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
    GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );
    GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
  }
*/
  // Initialize GATT attributes
 // GGS_AddService( GATT_ALL_SERVICES );            // GAP
 // GATTServApp_AddService( GATT_ALL_SERVICES );    // GATT attributes
 // DevInfo_AddService();                           // Device Information Service
 // SimpleProfile_AddService( GATT_ALL_SERVICES );  // Simple GATT Profile
BX_AddService( GATT_ALL_SERVICES );
/*
#if defined FEATURE_OAD
  VOID OADTarget_AddService();                    // OAD Profile
#endif
*/
  // Setup the SimpleProfile Characteristic Values
  {

  }





  // Register callback with SimpleGATTprofile
 // VOID SimpleProfile_RegisterAppCBs( &simpleBLEPeripheral_SimpleProfileCBs );

  // Enable clock divide on halt
  // This reduces active current while radio is active and CC254x MCU
  // is halted
 // HCI_EXT_ClkDivOnHaltCmd( HCI_EXT_ENABLE_CLK_DIVIDE_ON_HALT );




  // Setup a delayed profile startup
  osal_set_event( simpleBLEPeripheral_TaskID, SBP_START_DEVICE_EVT );

}
コード例 #12
0
ファイル: main.c プロジェクト: elsuizo/sAPI
/* FUNCION PRINCIPAL, PUNTO DE ENTRADA AL PROGRAMA LUEGO DE RESET. */
int main(void){

   /* ------------- INICIALIZACIONES ------------- */

   /* Inicializar la placa */
   boardConfig();

   /* Inicializar el conteo de Ticks con resolución de 1ms, sin tickHook */
   tickConfig( 1, 0 );

   /* Inicializar DigitalIO */
   digitalConfig( 0, ENABLE_DIGITAL_IO );

   /* Configuración de pines de entrada para Teclas de la CIAA-NXP */
   digitalConfig( TEC1, INPUT );
   digitalConfig( TEC2, INPUT );
   digitalConfig( TEC3, INPUT );
   digitalConfig( TEC4, INPUT );

   /* Configuración de pines de salida para Leds de la CIAA-NXP */
   digitalConfig( LEDR, OUTPUT );
   digitalConfig( LEDG, OUTPUT );
   digitalConfig( LEDB, OUTPUT );
   digitalConfig( LED1, OUTPUT );
   digitalConfig( LED2, OUTPUT );
   digitalConfig( LED3, OUTPUT );

   /* Inicializar UART_USB a 115200 baudios */
   uartConfig( UART_USB, 115200 );

   /* Inicializar AnalogIO */
   /* Posibles configuraciones:
    *    ENABLE_ANALOG_INPUTS,  DISABLE_ANALOG_INPUTS,
    *    ENABLE_ANALOG_OUTPUTS, DISABLE_ANALOG_OUTPUTS
    */
   analogConfig( ENABLE_ANALOG_INPUTS );  /* ADC */
   analogConfig( ENABLE_ANALOG_OUTPUTS ); /* DAC */

   /* Configuración de estado inicial del Led */
   bool_t ledState1 = OFF;

   /* Contador */
   uint32_t i = 0;

   /* Buffer */
   static uint8_t uartBuff[10];

   /* Variable para almacenar el valor leido del ADC CH1 */
   uint16_t muestra = 0;

   /* Variables de delays no bloqueantes */
   delay_t delay1;
   delay_t delay2;

   /* Inicializar Retardo no bloqueante con tiempo en ms */
   delayConfig( &delay1, 500 );
   delayConfig( &delay2, 200 );

   /* ------------- REPETIR POR SIEMPRE ------------- */
   while(1) {

      /* delayRead retorna TRUE cuando se cumple el tiempo de retardo */
      if ( delayRead( &delay1 ) ){

         /* Leo la Entrada Analogica AI0 - ADC0 CH1 */
         muestra = analogRead( AI0 );

         /* Envío la primer parte del mnesaje a la Uart */
         uartWriteString( UART_USB, (uint8_t*)"AI0 value: " );

         /* Conversión de muestra entera a ascii con base decimal */
         itoa( muestra, uartBuff, 10 ); /* 10 significa decimal */

         /* Enviar muestra y Enter */
         uartWriteString( UART_USB, uartBuff );
         uartWriteString( UART_USB, (uint8_t*)";\r\n" );

         /* Escribo la muestra en la Salida AnalogicaAO - DAC */
         analogWrite( AO, muestra );
      }

      /* delayRead retorna TRUE cuando se cumple el tiempo de retardo */
      if ( delayRead( &delay2 ) ){
         if( ledState1 )
            ledState1 = OFF;
         else
            ledState1 = ON;
         digitalWrite( LED1, ledState1 );

         /* Si pasaron 20 delays le aumento el tiempo */
         i++;
         if( i == 20 )
            delayWrite( &delay2, 1000 );
      }

   }

   /* NO DEBE LLEGAR NUNCA AQUI, debido a que a este programa no es llamado
      por ningun S.O. */
   return 0 ;
}
コード例 #13
0
ファイル: main.c プロジェクト: cpantel/ciaa
/*==================[declaraciones de funciones internas]====================*/
void setupUart() {
   uartConfig( UART_USB, 115200 );
   uartWriteString( UART_USB, "ready osek ej04osek build 0004\n");
}
コード例 #14
0
ファイル: AnalogPi.c プロジェクト: sankarcheppali/Atmega8
void sendResponse(uint8_t *data)
{
  uartWriteByte(0x0D);
  uartWriteString(data);
  uartWriteByte(0x0A);
}
コード例 #15
0
ファイル: main.c プロジェクト: cpantel/ciaa
void AsteriskInit() {
   uartConfig( UART_USB, 115200 );
   uartWriteString( UART_USB, "ready osek ej10\n");
}