Exemplo n.º 1
0
void fpga_spiinitgpio(uint32_t DSP_FPGA_CSGPIO)
{

			gpioInit();
    		gpioSetDirection(DSP_FPGA_CSGPIO,GPIO_OUT);
    		gpioSetOutput(DSP_FPGA_CSGPIO);

}
Exemplo n.º 2
0
/* Initis the ports that use the buttons.
 *
 * Ports:
 * PB0 - PB5 : GPIO Inputs.
 *
 */
void buttonsInit(){
	gpioSetMasterEnable(GPIO_PORTB);
	gpioSetDirection(GPIO_PORTB,BUTTONS_ENABLED_BUTTONS,0x00);
	gpioSetDigitalEnable(GPIO_PORTB,BUTTONS_ENABLED_BUTTONS,BUTTONS_ENABLED_BUTTONS);

	gpioSetPullUpSelect(GPIO_PORTB,0x3F,0x3F);

	gpioSetInterruptBothEdges(GPIO_PORTB,BUTTONS_ENABLED_BUTTONS,0x00);
	gpioSetInterruptEvent(GPIO_PORTB,BUTTONS_ENABLED_BUTTONS,0x00);
	gpioHelperInterruptMasterEnable();
	gpioSetInterruptEnable(GPIO_PORTB);
	buttonsEnable();
}
BOOL Gpio_Init()
{
	int32_t pinNum;
	//CSL_GpioHandle  hGpio;
	    if( bGpioInitialized == TRUE)
	    	{
	    		return TRUE;
	    	}
	    // Open the CSL GPIO Module 0
	    GpioHandle = CSL_GPIO_open (0);

		// Disable the GPIO global interrupts
		CSL_GPIO_bankInterruptEnable(GpioHandle, GPIOBANKNUM);

		// Clear all falling edge trigger and rising edge trigger
		for (pinNum = GPIO_0; pinNum <= GPIO_15; pinNum++) {
	        CSL_GPIO_clearFallingEdgeDetect(GpioHandle, pinNum);
	        CSL_GPIO_clearRisingEdgeDetect (GpioHandle, pinNum);
	    }

		// Set all GPIO as input
	    //	GPIOREGS->DIR = GPIOREGS->DIR & 0xffffffff;

		// Configure the GPIOs for NAND flash controller communication
		// Configure data bus as output
		//gpioSetDataBusDirection(GPIO_OUT);
	#ifdef EVMBOARD
		// Configure the signal pins direction
		gpioSetDirection(DSP_FPGA_CMD0, GPIO_OUT );
		gpioSetDirection(DSP_FPGA_CMD1, GPIO_OUT );

		gpioSetDirection(DSP_FPGA_STROBE, GPIO_OUT );
		gpioSetDirection(FPGA_DSP_READY, GPIO_IN );
	#endif
    bGpioInitialized = TRUE;

	return TRUE;
}
Exemplo n.º 4
0
// Initialize GPIO module
void MW_gpioInit(int32_T gpio, boolean_T direction, uint32_T internalResistor, const uint8_T *pinName)
{
    GPIO_info *gpioInfoPtr;
    
    gpioInfo = realloc(gpioInfo, (numGpio + 1) * sizeof(GPIO_info));
    if (gpioInfo == NULL) {
        fprintf(stderr, "Error allocating memory for GPIO pin %d.\n", gpio);
        MW_gpioExit();
    }
    gpioInfoPtr = gpioInfo + numGpio;
    
    //Fill in GPIO info structure for the GPIO module
#ifdef _DEBUG
    printf("gpio = %d, direction = %d, internalRes = %d, pinName = %s\n", 
        gpio, direction, internalResistor, pinName);
#endif
    gpioInfoPtr->gpio             = gpio;
    gpioInfoPtr->direction        = direction;
    gpioInfoPtr->internalResistor = internalResistor;
    gpioInfoPtr->fd               = -1;
    strcpy(&(gpioInfoPtr->pinName[0]), pinName); 
    numGpio++;
    
    // Set pin muxing and claim GPIO pin
    if (setGpioPinMux(pinName, direction, internalResistor) < 0) {
        fprintf(stderr, "Error setting PIN MUX.\n");
        MW_gpioExit();
    }
    if (gpioExport(gpio) < 0) {
        fprintf(stderr, "Error exporting GPIO pin.\n");
        MW_gpioExit();
    }
	if (gpioSetDirection(gpio, direction) < 0) { 
        fprintf(stderr, "Error setting GPIO pin direction.\n");
        MW_gpioExit();
    }
	gpioInfoPtr->fd = gpioOpen(gpio, direction);
    if (gpioInfoPtr->fd < 0) {
        fprintf(stderr, "Error opening GPIO.\n");
        MW_gpioExit();
    }
#ifdef _DEBUG
    MW_dumpGpioInfo("INIT");
#endif
}
Exemplo n.º 5
0
// custom the robot behaviors
// init_robot_gpio
void init_robot_gpio(void)
{
  gpioExport(OUT1);
  gpioSetDirection(OUT1, outputPin);
  gpioExport(OUT2);
  gpioSetDirection(OUT2, outputPin);
  gpioExport(OUT3);
  gpioSetDirection(OUT3, outputPin);
  gpioExport(OUT4);
  gpioSetDirection(OUT4, outputPin);
  gpioExport(ENGINE_LEFT);
  gpioSetDirection(ENGINE_LEFT, outputPin);
  gpioExport(ENGINE_RIGHT);
  gpioSetDirection(ENGINE_RIGHT, outputPin);
}
Exemplo n.º 6
0
int hpdspuaStart (void) {

	   uint32_t coreId;
	   QMSS_CFG_T      qmss_cfg;
	      CPPI_CFG_T      cppi_cfg;
	   /* determine the core number. */
	      coreId = CSL_chipReadReg (CSL_CHIP_DNUM);
	      led_no=coreId;

	      platform_write("num of cores  %d starts twinkling its LED\n", number_of_cores);
	      platform_write("core = %d starts twinkling its LED\n", coreId);
	      //platform_uart_init();
	      //platform_uart_set_baudrate(115200);
//	      write_uart("AAAAAAAA");
	      gpioInit();
	      gpioSetDirection(GPIO_10 ,GPIO_IN);   //DOUTA pin
	      gpioSetDirection(GPIO_3 ,GPIO_OUT);   //CNVST pin
	      gpioSetDirection(GPIO_13 ,GPIO_OUT);  //CS pin
	      gpioSetDirection(GPIO_7 ,GPIO_OUT);  //SCLK

	      //ADDR = 0, VA1 and VB1 are sampled;  ADDR =1, VA2 and VB2 are sampled
	      //Right now VA1 and VB1 are being sampled
	      gpioSetOutput(GPIO_7);   //By default clock high
	      gpioSetOutput(GPIO_3);   // by default conversion pin high
	      gpioSetOutput(GPIO_13);   // BY Default CS pin high

          gpioSetFallingEdgeInterrupt(GPIO_10);
          gpioSetRisingEdgeInterrupt(GPIO_10);
	  	  gpioEnableGlobalInterrupt();

	  	  //Wait for 100us before starting first conversion
	      platform_delay(100);
	      int rc=0;
	      while(1) {
		    if(coreId==0)
		    {



		    	    if (platform_get_coreid() == 0)
		    	    {
		    	        qmss_cfg.master_core        = 1;
		    	    }
		    	    else
		    	    {
		    	        qmss_cfg.master_core        = 0;
		    	    }
		    	    qmss_cfg.max_num_desc       = MAX_NUM_DESC;
		    	    qmss_cfg.desc_size          = MAX_DESC_SIZE;
		    	    qmss_cfg.mem_region         = Qmss_MemRegion_MEMORY_REGION0;
		    	    if (res_mgr_init_qmss (&qmss_cfg) != 0)
		    	    {
		    	        platform_write ("Failed to initialize the QMSS subsystem \n");
		    	        goto main_exit;
		    	    }
		    	    else
		    	    {
		    	        platform_write ("QMSS successfully initialized \n");
		    	    }


		    	    if (platform_get_coreid() == 0)
		    	    {
		    	        cppi_cfg.master_core        = 1;
		    	    }
		    	    else
		    	    {
		    	        cppi_cfg.master_core        = 0;
		    	    }
		    	    cppi_cfg.dma_num            = Cppi_CpDma_PASS_CPDMA;
		    	    cppi_cfg.num_tx_queues      = NUM_PA_TX_QUEUES;
		    	    cppi_cfg.num_rx_channels    = NUM_PA_RX_CHANNELS;
		    	    if (res_mgr_init_cppi (&cppi_cfg) != 0)
		    	    {
		    	        platform_write ("Failed to initialize CPPI subsystem \n");
		    	        goto main_exit;
		    	    }
		    	    else
		    	    {
		    	        platform_write ("CPPI successfully initialized \n");
		    	    }


		    	    if (res_mgr_init_pass()!= 0) {
		    	        platform_write ("Failed to initialize the Packet Accelerator \n");
		    	        goto main_exit;
		    	    }
		    	    else
		    	    {
		    	        platform_write ("PA successfully initialized \n");
		    	    }



		    	    rc = NC_SystemOpen( NC_PRIORITY_HIGH, NC_OPMODE_INTERRUPT );

		    	    if( rc ) {
		    	        platform_write("NC_SystemOpen Failed (%d). Will die in an infinite loop so you need to reset...\n",rc);
		    	        for(;;);
		    	    }

		    	    platform_write("HUA version %s\n", BLM_VERSION);

		    	        hCfg = CfgNew();
		    	    if( !hCfg )
		    	    {
		    	        platform_write("Unable to create a configuration for the IP stack.\n");
		    	        goto main_exit;
		    	    }


		    	    strcpy (HostName, "tidemo-");
		    	    i = strlen(HostName);
		    	    j = strlen(gPlatformInfo.serial_nbr);

		    	    if (j > 0) {
		    	        if (j > 6) {
		    	            memcpy (&HostName[i], &gPlatformInfo.serial_nbr[j-6], 6);
		    	            HostName[i+7] = '\0';
		    	        }
		    	        else {
		    	            memcpy (&HostName[i], gPlatformInfo.serial_nbr, j);
		    	            HostName[i+j+1] = '\0';
		    	        }
		    	    }


		    	    if( strlen( DomainName ) >= CFG_DOMAIN_MAX ||
		    	        strlen( HostName ) >= CFG_HOSTNAME_MAX )
		    	    {
		    	        platform_write("Domain or Host Name too long\n");
		    	        goto main_exit;
		    	    }

		    	    platform_write("Setting hostname to %s \n", HostName);

		    	    platform_write("MAC Address: %02X-%02X-%02X-%02X-%02X-%02X \n",
		    	            gPlatformInfo.emac.efuse_mac_address[0], gPlatformInfo.emac.efuse_mac_address[1],
		    	            gPlatformInfo.emac.efuse_mac_address[2], gPlatformInfo.emac.efuse_mac_address[3],
		    	            gPlatformInfo.emac.efuse_mac_address[4], gPlatformInfo.emac.efuse_mac_address[5]);

		    	    CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
		    	                 strlen(HostName), (uint8_t *)HostName, 0 );

		    	    if (!platform_get_switch_state(1)) {

		    	        CI_IPNET NA;
		    	        CI_ROUTE RT;
		    	        IPN      IPTmp;
		    	        bzero( &NA, sizeof(NA) );
		    	        NA.IPAddr  = inet_addr(EVMStaticIP);
		    	        NA.IPMask  = inet_addr(LocalIPMask);
		    	        strcpy( NA.Domain, DomainName );


		    	        CfgAddEntry( hCfg, CFGTAG_IPNET, 1, 1, sizeof(CI_IPNET), (uint8_t *)&NA, 0 );

		    	        bzero( &RT, sizeof(RT) );
		    	        RT.IPDestAddr = inet_addr(PCStaticIP);
		    	        RT.IPDestMask = inet_addr(LocalIPMask);
		    	        RT.IPGateAddr = inet_addr(GatewayIP);

		    	        CfgAddEntry( hCfg, CFGTAG_ROUTE, 0, 1, sizeof(CI_ROUTE), (uint8_t *)&RT, 0 );


		    	        platform_write("EVM in StaticIP mode at %s\n",EVMStaticIP);
		    	        platform_write("Set IP address of PC to %s\n", PCStaticIP);
		    	    }




		    	       rc = DBG_WARN;
		    	    CfgAddEntry( hCfg, CFGTAG_OS, CFGITEM_OS_DBGPRINTLEVEL,
		    	                 CFG_ADDMODE_UNIQUE, sizeof(uint), (uint8_t *)&rc, 0 );

		    	       rc = 64000;
		    	    CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPTXBUF,
		    	                 CFG_ADDMODE_UNIQUE, sizeof(uint), (uint8_t *)&rc, 0 );

		    	    rc = 64000;
		    	    CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXBUF,
		    	                 CFG_ADDMODE_UNIQUE, sizeof(uint), (uint8_t *)&rc, 0 );

		    	    rc = 64000;
		    	    CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXLIMIT,
		    	                 CFG_ADDMODE_UNIQUE, sizeof(uint), (uint8_t *)&rc, 0 );

		    	    rc = 8192;
		    	    CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKUDPRXLIMIT,
		    	                 CFG_ADDMODE_UNIQUE, sizeof(uint), (uint8_t *)&rc, 0 );


		    	    do
		    	    {
		    	        rc = NC_NetStart( hCfg, NetworkOpen, NetworkClose, NetworkIPAddr );
		    	    } while( rc > 0 );



		    	    platform_write("Done with this utility. Shutting things down\n");





		    	    CfgFree( hCfg );


		    	main_exit:
		    	    platform_write("Exiting the system\n");
		    	    //NC_SystemClose();
		    	    TaskExit();
		    	    return(0);


		    }
		    else
		    {
		    	while(1)
		    	{
		    		platform_write("done processing .exiting core %d \n", coreId);
		    		platform_delay(300000);
		    		break;
		    	}
		    	platform_delay(300000);
		    	break;
		    }
	 }

	 platform_write("done processing .exiting core %d", coreId);

	 platform_delay(3000000);
	 return 0;
}
Exemplo n.º 7
0
static int
ili9341_init(ILI9341PyObject *self, PyObject *args, PyObject *kwds) {
	int i;
	int bus, chip_select, pin_dc, pin_reset;
	char path[SPIDEV_MAXPATH];
	static char *kwlist[] = {"bus", "chip_select", "dc", "reset", NULL};

	if (!PyArg_ParseTupleAndKeywords(args, kwds, "iiii", kwlist, &bus, &chip_select, &pin_dc, &pin_reset))
		return -1;

	if (snprintf(path, SPIDEV_MAXPATH, "/dev/spidev%d.%d", bus, chip_select) >= SPIDEV_MAXPATH) {
		return -1;
	}

	if ((self->fd = open(path, O_RDWR)) < 0) {
		return -1;
	}

	// setup CS and RST pins
	self->pin_dc = pin_dc;
	self->pin_reset = pin_reset;

	gpioExport(self->pin_dc);
	gpioSetDirection(self->pin_dc, OUTPUT);
	self->fd_dc = gpioOpenSet(self->pin_dc);

	gpioExport(self->pin_reset);
	gpioSetDirection(self->pin_reset, OUTPUT);
	self->fd_reset = gpioOpenSet(self->pin_reset);

	self->width = ILI9341_TFTWIDTH;
	self->height = ILI9341_TFTHEIGHT;
	self->color = 0xffff;
	self->bg_color = 0;
	self->cursor_x = 0;
	self->cursor_y = 0;

	self->font = System5x7;
	self->char_spacing = 1;

	TFT_DC_HIGH;

	TFT_RST_LOW;
	for(i=0; i<0x7FFFFF; i++);
	TFT_RST_HIGH;

	TFT_sendCMD(self, 0xEF);
	TFT_sendDATA(self, 0x03);
	TFT_sendDATA(self, 0x80);
	TFT_sendDATA(self, 0x02);
  
	TFT_sendCMD(self, 0xCB);
	TFT_sendDATA(self, 0x39);
	TFT_sendDATA(self, 0x2C);
	TFT_sendDATA(self, 0x00);
	TFT_sendDATA(self, 0x34);
	TFT_sendDATA(self, 0x02);
  
	TFT_sendCMD(self, 0xCF);
	TFT_sendDATA(self, 0x00);
	TFT_sendDATA(self, 0xC1);
	TFT_sendDATA(self, 0x30);

	TFT_sendCMD(self, 0xE8);
	TFT_sendDATA(self, 0x85);
	TFT_sendDATA(self, 0x00);
	TFT_sendDATA(self, 0x78);

	TFT_sendCMD(self, 0xEA);
	TFT_sendDATA(self, 0x00);
	TFT_sendDATA(self, 0x00);

	TFT_sendCMD(self, 0xED);
	TFT_sendDATA(self, 0x64);
	TFT_sendDATA(self, 0x03);
	TFT_sendDATA(self, 0x12);
	TFT_sendDATA(self, 0x81);

	TFT_sendCMD(self, 0xF7);
	TFT_sendDATA(self, 0x20);

	TFT_sendCMD(self, ILI9341_PWCTR1);    	//Power control
	TFT_sendDATA(self, 0x23);   	//VRH[5:0]

	TFT_sendCMD(self, ILI9341_PWCTR2);    	//Power control
	TFT_sendDATA(self, 0x10);   	//SAP[2:0];BT[3:0]

	TFT_sendCMD(self, ILI9341_VMCTR1);    	//VCM control
	TFT_sendDATA(self, 0x3e);   	//Contrast
	TFT_sendDATA(self, 0x28);

	TFT_sendCMD(self, ILI9341_VMCTR2);    	//VCM control2
	TFT_sendDATA(self, 0x86);  	 //--

	TFT_sendCMD(self, ILI9341_MADCTL);    	// Memory Access Control
	TFT_sendDATA(self, MADCTL_MX | MADCTL_BGR);

	TFT_sendCMD(self, ILI9341_PIXFMT);
	TFT_sendDATA(self, 0x55);

	TFT_sendCMD(self, ILI9341_FRMCTR1);
	TFT_sendDATA(self, 0x00);
	TFT_sendDATA(self, 0x18);

	TFT_sendCMD(self, ILI9341_DFUNCTR);    	// Display Function Control
	TFT_sendDATA(self, 0x08);
	TFT_sendDATA(self, 0x82);
	TFT_sendDATA(self, 0x27);

	TFT_sendCMD(self, 0xF2);    	// 3Gamma Function Disable
	TFT_sendDATA(self, 0x00);

	TFT_sendCMD(self, ILI9341_GAMMASET);    	//Gamma curve selected
	TFT_sendDATA(self, 0x01);

	TFT_sendCMD(self, ILI9341_GMCTRP1);    	//Set Gamma
	TFT_sendDATA(self, 0x0F);
	TFT_sendDATA(self, 0x31);
	TFT_sendDATA(self, 0x2B);
	TFT_sendDATA(self, 0x0C);
	TFT_sendDATA(self, 0x0E);
	TFT_sendDATA(self, 0x08);
	TFT_sendDATA(self, 0x4E);
	TFT_sendDATA(self, 0xF1);
	TFT_sendDATA(self, 0x37);
	TFT_sendDATA(self, 0x07);
	TFT_sendDATA(self, 0x10);
	TFT_sendDATA(self, 0x03);
	TFT_sendDATA(self, 0x0E);
	TFT_sendDATA(self, 0x09);
	TFT_sendDATA(self, 0x00);

	TFT_sendCMD(self, ILI9341_GMCTRN1);    	//Set Gamma
	TFT_sendDATA(self, 0x00);
	TFT_sendDATA(self, 0x0E);
	TFT_sendDATA(self, 0x14);
	TFT_sendDATA(self, 0x03);
	TFT_sendDATA(self, 0x11);
	TFT_sendDATA(self, 0x07);
	TFT_sendDATA(self, 0x31);
	TFT_sendDATA(self, 0xC1);
	TFT_sendDATA(self, 0x48);
	TFT_sendDATA(self, 0x08);
	TFT_sendDATA(self, 0x0F);
	TFT_sendDATA(self, 0x0C);
	TFT_sendDATA(self, 0x31);
	TFT_sendDATA(self, 0x36);
	TFT_sendDATA(self, 0x0F);

	TFT_sendCMD(self, ILI9341_SLPOUT);    	//Exit Sleep
	for(i=0; i<0x7FFFFF; i++);

	TFT_sendCMD(self, ILI9341_DISPON);    //Display on
	TFT_sendCMD(self, 0x2c);

	return 0;
}