Ejemplo n.º 1
0
void init_platform( void )
{
    PORT_HAL_SetMuxMode(PORTC_BASE,3u,kPortMuxAsGpio);
    PORT_HAL_SetMuxMode(PORTC_BASE,4u,kPortMuxAsGpio);
    GPIO_DRV_OutputPinInit(&ledPins[0]);
    GPIO_DRV_OutputPinInit(&ledPins[1]);
    OSA_Init();

}
Ejemplo n.º 2
0
OSStatus host_platform_bus_init( void )
{
    edma_user_config_t g_edmaUserConfig;

    /* Create a semephore to check for completed eDMA transfers. */
    mico_rtos_init_semaphore(&spi_transfer_finished_semaphore, 1);
    MCU_CLOCKS_NEEDED();
    
    configure_spi_pins(0); // initlize spi0 GPIO
    PORT_HAL_SetMuxMode(PORTD_BASE,0u,kPortMuxAsGpio); // configure CS as gpio, use software configure CS.
    GPIO_DRV_OutputPinInit(&spiCsPin[0]);
    SPI0_CS_DISABLE;
    /* Initialize eDMA & DMAMUX */
    g_edmaUserConfig.chnArbitration = kEDMAChnArbitrationRoundrobin;
    g_edmaUserConfig.notHaltOnError = false;
    EDMA_DRV_Init(&g_edmaState, &g_edmaUserConfig);
    /* DSPI Master Configuration */
    dspi_edma_master_setup(&dspiMasterState, 0, 10000000, 8);
    
    MCU_CLOCKS_NOT_NEEDED();
    dmaSPITX.dmaChanNum = DMA_CH0;
    dmaSPITX.dmaCh = &dmaCh0;
    dmaSPITX.type = kEDMAMemoryToPeripheral;
    dmaSPITX.chSource = kDmaRequestMux0SPI0Tx;
    dmaSPITX.srcAddr = (uint32_t)NULL;
    dmaSPITX.destAddr = (uint32_t)&SPI0->PUSHR;
    dmaSPITX.length = 0;
    dmaSPITX.size = 4;
    dmaSPITX.watermark = 4;
    dmaSPITX.period = 0x01U;
    dmaSPITX.dmaCallBack = stop_edma_loop;
    

    dmaSPIRX.dmaChanNum = DMA_CH1;
    dmaSPIRX.dmaCh = &dmaCh1;
    dmaSPIRX.type = kEDMAPeripheralToMemory;
    dmaSPIRX.chSource = kDmaRequestMux0SPI0Rx;
    dmaSPIRX.srcAddr = (uint32_t)&SPI0->POPR;
    dmaSPIRX.destAddr = (uint32_t)NULL;
    dmaSPIRX.length = 0;
    dmaSPIRX.size = 1;
    dmaSPIRX.watermark = 1;
    dmaSPIRX.period = 0x01U;
    dmaSPIRX.dmaCallBack = stop_edma_loop_putsem;
    dmaSPIRX.dmaChStcd = (edma_software_tcd_t *)mem_align(2 * sizeof(edma_software_tcd_t) * dmaSPIRX.period, 32);

    spi_status_print(SPI0);
    return kNoErr;
}
Ejemplo n.º 3
0
int main (void)
{
   OSA_Init();

   /* Initialize clocks, debug console interface and configure required pins */
   hardware_init();

   /* Disable Memory Protection Unit */
   MPU_HAL_Disable(MPU);

	testPin.pinName = test_pin_name;
	testPin.config.outputLogic = 0;
	testPin.config.slewRate = kPortFastSlewRate;
	testPin.config.driveStrength = kPortHighDriveStrength;
	testPin.config.isOpenDrainEnabled = false;
	GPIO_DRV_OutputPinInit(&testPin);

	// Structure of initialize PIT channel No.0
   pit_user_config_t chn0Confg;
   chn0Confg.isInterruptEnabled = true;
   chn0Confg.periodUs = 1000000u;

   // Init pit module and enable run in debug
   PIT_DRV_Init(BOARD_PIT_INSTANCE, false);

   // Initialize PIT timer instance for channel 0 and 1
   PIT_DRV_InitChannel(BOARD_PIT_INSTANCE, 0, &chn0Confg);

   // Start channel 0
   PRINTF("\n\rStarting channel No.0 ...");
   PIT_DRV_StartTimer(BOARD_PIT_INSTANCE, 0);

//	drv_Mpu9250.Init();
	sdCard.Init(1);

   OSA_TaskCreate((task_t)MainTask,   (uint8_t*)"Main Task",    4096, NULL, 2, NULL, true, NULL);
   //OSA_TaskCreate((task_t)FnetTask,   (uint8_t*)"FNET Task",    2048, NULL, 3, NULL, true, NULL);

   OSA_Start(); // This function will not return

   while(1);

   return(0);
}
Ejemplo n.º 4
0
/*FUNCTION**********************************************************************
 *
 * Function Name : GPIO_DRV_Init
 * Description   : Initialize all GPIO pins used by board.
 * To initialize the GPIO driver, two arrays similar with gpio_input_pin_user_config_t
 * inputPin[] and gpio_output_pin_user_config_t outputPin[] should be defined in user's file.
 * Then simply call GPIO_DRV_Init() and pass into these two arrays. If input or output
 * pins are not needed, pass in a NULL.  
 *
 *END**************************************************************************/
void GPIO_DRV_Init(const gpio_input_pin_user_config_t * inputPins,
                   const gpio_output_pin_user_config_t * outputPins)
{
    if (inputPins)
    {
        /* Initialize input pins.*/
        while (inputPins->pinName != GPIO_PINS_OUT_OF_RANGE)
        {
            GPIO_DRV_InputPinInit(inputPins++);
        }
    }

    if (outputPins)
    {
        /* Initialize output pins.*/
        while (outputPins->pinName != GPIO_PINS_OUT_OF_RANGE)
        {
            GPIO_DRV_OutputPinInit(outputPins++);
        }
    }
}
Ejemplo n.º 5
0
/*****************************************************************************
*  EEPROM_Init
*
*  Initializes the EEPROM peripheral
*
*****************************************************************************/
ee_err_t EEPROM_Init(void)
{
    ee_err_t retval;
    spiBusConfig_t spiConfig = {
        .bitsPerSec = 2000000,
        .master = TRUE,
        .clkActiveHigh = TRUE,
        .clkPhaseFirstEdge = TRUE,
        .MsbFirst = TRUE
    };
    
    #if gEepromWriteEnable_d
    uint32_t i;

    // Mark Flash as Unerased
    for(i = 0; i < 64; i++)
        mEepromEraseBitmap[i] = 0;
#endif

    if(Spi_Init(gEepromSpiInstance_c, &mEepromSpiState, NULL, NULL) != spiSuccess)
    {
        return ee_error;
    }
    
    if(Spi_Configure(gEepromSpiInstance_c, &spiConfig) != spiSuccess)
    {
        return ee_error;
    }
    
    GPIO_DRV_OutputPinInit(&mEepromSpiCsCfg);
    PORT_HAL_SetMuxMode(g_portBase[GPIO_EXTRACT_PORT(gEepromSpiCsPin_d)],
                        GPIO_EXTRACT_PIN(gEepromSpiCsPin_d), 
                        kPortMuxAsGpio);   
    
    gEepromDeassertCS_d();
    
    return ee_ok;
}

/*****************************************************************************
*  EEPROM_ChipErase
*
*  Erase all memory to 0xFF
*
*****************************************************************************/
ee_err_t EEPROM_ChipErase(void)
{
    // make sure the write process is ready
    while(EEPROM_GetWriteReady() != ee_ok);
    
    return EEPROM_SendCmd(EEPROM_CMD_ERASE_BULK, EEPROM_CMD_END);
}

/*****************************************************************************
*  EEPROM_EraseBlock
*
*  Erase a block of memory to 0xFF
*
*****************************************************************************/
ee_err_t EEPROM_EraseBlock(uint32_t Addr, uint32_t size)
{
    ee_err_t status = ee_ok;
    
    if(size != EEPROM_SECTOR_SIZE)
    {
        return ee_error;
    }
    
    // make sure the write process is ready
    while(EEPROM_GetWriteReady() != ee_ok);
    
    // send the command
    status |= EEPROM_SendCmd( EEPROM_CMD_ERASE_SECTOR, EEPROM_CMD_CNT );
    
    // send the address
    status |= EEPROM_SendAddress(Addr);

    if (status == ee_ok)
    {
        gEepromDeassertCS_d();
        return ee_ok;
    }
    else
    {
        return ee_error;
    }
}