Ejemplo n.º 1
0
/********************************************************************************************************
 * @fn      ZMacInit
 *
 * @brief   Initialize MAC.
 *
 * @param   none.
 *
 * @return  status.
 ********************************************************************************************************/
uint8 ZMacInit( void )
{
  uint8 stat;

#if defined( ZCL_KEY_ESTABLISH )
  /* Set the callback function for 16 byte random seed */
  MAC_SetRandomSeedCB( SSP_StoreRandomSeedNV);
#endif

  MAC_Init();
  MAC_InitDevice();

#if !defined NONWK
  if ( ZG_BUILD_RTR_TYPE )
  {
    MAC_InitCoord();
  }
#endif

  // If OK, initialize the MAC
  stat = ZMacReset( TRUE );

  // Turn off interrupts
  osal_int_disable( INTS_ALL );

  return ( stat );
}
Ejemplo n.º 2
0
/**************************************************************************************************
 * @fn          main
 *
 * @brief       Start of application.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
int main(void)
{
  /* Initialize hardware */
  HAL_BOARD_INIT();

  /* Initialze the HAL driver */
  HalDriverInit();

  /* Initialize MAC */
  MAC_Init();

  /* Initialize the operating system */
  osal_init_system();

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  /* Setup OSAL Timer */
  HalTimerConfig ( OSAL_TIMER,                         // 16bit timer3
                   HAL_TIMER_MODE_CTC,                 // Clear Timer on Compare
                   HAL_TIMER_CHANNEL_SINGLE,           // Channel 1 - default
                   HAL_TIMER_CH_MODE_OUTPUT_COMPARE,   // Output Compare mode
                   FALSE,                              // Use interrupt
                   MSA_Main_TimerCallBack);            // Channel Mode

  /* Setup Keyboard callback */
  HalKeyConfig(MSA_KEY_INT_ENABLED, MSA_Main_KeyCallback);

  /* Initialize UART */
  UartCnfg.baudRate = HAL_UART_BR_9600;
  UartCnfg.callBackFunc = HalUARTCBack;
  UartCnfg.flowControl = FALSE;
  UartCnfg.flowControlThreshold = 0;  /* max Buffer Size in Byte*/
  UartCnfg.idleTimeout = 200;

  /*
   * halUARTOpen provvederà tramite la funzione halUartAllocBuffers ad allocare e inizializzare
   * le strutture dati RxUART e TxUART.
   */

  UartCnfg.rx = RxUART;
  UartCnfg.tx = TxUART;
  UartCnfg.rx.maxBufSize = UART_MAX_BUFFER_SIZE;
  UartCnfg.tx.maxBufSize = UART_MAX_BUFFER_SIZE;
  UartCnfg.intEnable = TRUE ;  /* enable or disable the interrupts */
  UartCnfg.configured = TRUE;

  uint8 status = HalUARTOpen(HAL_UART_PORT, &UartCnfg); /* passo l'indirizzo di memoria della struttura dati
  	  	  	  	  	  	  	  	  	  	  UartCnfg, Passaggio per riferimento!!!*/




  /* Start OSAL */
  osal_start_system(); // No Return from here

  return 0;
}
Ejemplo n.º 3
0
//FIRST DIES AT 5000 Hz
//------------------------------------------------------------------------------------
// MAIN Routine
//------------------------------------------------------------------------------------
void main(void)
{
	char high=0;
	char low = 0;
	WDTCN = 0xDE;						// Disable the watchdog timer
	WDTCN = 0xAD;						// Note: = "DEAD"!
	
	SYSCLK_INIT();						// Initialize the oscillator
	PORT_INIT();						// Initialize the Crossbar and GPIO
	UART0_INIT();						// Initialize UART0
	ADC_Init();							// Initialize ADC0
	DAC_Init();							// Initialize DAC0
	MAC_Init();							// Initialize MAC0

	SFRPAGE = UART0_PAGE;				// Direct output to UART0

	//initialize ADC converter

	//select 00 on AD0CM mux
	ADC0CN &= ~0x0C;
	//clear AD0INT
	AD0INT = 0;
	//AD0BUSY = 1 to start conversion
	AD0BUSY = 1;

	//while AD0INT != 0
	while(AD0INT != 0);


	printf("\033[2J");					//clear screen
	printf("We will not sow. \n\r");		//running

	while(1)
	{
		//printf("Still running. \n\r");
		olderIn = oldIn;
		oldIn = input;
		input = do_ADC();

		oldOut = output;
		output = do_MAC();

		do_DAC();

	//	printf("I: %d  I1: %d  I2: %d  O: %d  O2: %d \n\r", input, oldIn, olderIn, output, oldOut); 
	}

}
Ejemplo n.º 4
0
/********************************************************************************************************
 * @fn      ZMacInit
 *
 * @brief   Initialize MAC.
 *
 * @param   none.
 *
 * @return  status.
 ********************************************************************************************************/
ROOT uint8 ZMacInit( void )
{
  uint8 stat;

  MAC_Init();
  MAC_InitDevice();

#if defined ( RTR_NWK )
  MAC_InitCoord();
#endif

  // If OK, initialize the MAC
  stat = ZMacReset( TRUE );

  // Turn off interrupts
  osal_int_disable( INTS_ALL );

  return ( stat );
}
Ejemplo n.º 5
0
unsigned char RPC_Init(unsigned char addr)
{
  
  unsigned char status; 

  rpc_addr = addr;
  status = MAC_Init(addr);
  if (status != 0)
    return status;
  rpcTableSize = 0;

  while (RPC_Table[rpcTableSize].procedure != NULL)
    rpcTableSize++;
  DELAYMS(200);
  DELAYMS(200);
  DELAYMS(200);
  DELAYMS(200);
  DELAYMS(200);

  return 0;
}
Ejemplo n.º 6
0
/**************************************************************************************************
 * @fn          main
 *
 * @brief       Start of application.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
int main(void)
{
  /* Initialize hardware */
  HAL_BOARD_INIT();

  /* Initialze the HAL driver */
  HalDriverInit();

  /* Initialize MAC */
  MAC_Init();

  /* Initialize the operating system */
  osal_init_system();

#ifdef HAL_BOARD_CC2538
  /* Master enable interrupts */
  IntMasterEnable();

  /* Setup SysTick to generate interrupt every 1 ms */
  SysTickSetup();
#endif /* HAL_BOARD_CC2538 */

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  /* Setup Keyboard callback */
  HalKeyConfig(MSA_KEY_INT_ENABLED, MSA_Main_KeyCallback);

  /* Blink LED on startup */
  HalLedBlink (HAL_LED_4, 0, 40, 200);

  /* Start OSAL */
  OSAL_START_SYSTEM();

  return 0;
}
Ejemplo n.º 7
0
static int 
TestHMACkat(
            HASH_Algorithm      algor,
            uint8_t *              key,
            size_t				keyLen,
            char *				data,
            uint8_t				dataLen,
            uint8_t *              expected )

{
    int                 err     = CRYPT_OK;
    MAC_ContextRef     hmac = kInvalidMAC_ContextRef;
    
    size_t				hashSize = 0;
    size_t				resultLen;
    uint8_t                hmacBuf[64];
        
    err  = MAC_Init(kMAC_Algorithm_HMAC, algor,key, keyLen,  &hmac); CKERR;
 
    err = MAC_HashSize(hmac,  &hashSize);CKERR;
    
    err  = MAC_Update( hmac,  (uint8_t*)data, dataLen);CKERR;
 
    resultLen = hashSize;
    err  = MAC_Final( hmac, hmacBuf, &resultLen);CKERR;
    
     /* check against know answer */
	err = compareResults( expected, hmacBuf, resultLen , kResultFormat_Byte, hash_algor_table(algor)); CKERR;
      
done:
    
    if(!IsNull(hmac)) 
        MAC_Free(hmac);
  
	return err;
}