Esempio n. 1
0
int main(void)
{
	char str[20];
	unsigned int channel0;
	unsigned int channel1;
	float lux;

	SPI_Initialize();					//Initialize SPI peripheral
	TFT_Initialize();
	
	I2C_Initialize(APDS9300ADDR);		//Initialize I2C and setup chip address	
	
	AL_Initialize();					//Setup Ambient light sensor

	Image_t LampOn = {_acLampON,100,100};
	TFT_Background(WHITE);
	
	TFT_DisplayImage(&LampOn,5,5);
	
    while(1)
    { 	 
		channel0 = AL_ReadChannel(CH0);		//Take a reading from channel one
		channel1 = AL_ReadChannel(CH1);		//Take a reading from channel two	
        lux = AL_Lux(channel0,channel1);
		sprintf(str, "%3.2f Lx ", lux);
		TFT_PrintString(10,140,RED,WHITE,str,2);
		delay_ms(1000);
    }

    return 0;
}
Esempio n. 2
0
/*
*********************************************************************************************************
*                                           Init_ADC_Current()
*
* Description : Initialize the ADC for current measurement.
*
* Argument(s) : None.
*
* Return(s)   : None.
* 
* Caller(s)   : 
*
* Note(s)     : None.
*********************************************************************************************************
*/
void Init_ADC_Current( void )
{  
  
  SPI_Initialize( spi_adc, NPCS_AD7799, 1000000, MCK ) ;   // Configure SPI 
  
  //Init_AD7799(0);
  
}
Esempio n. 3
0
int main(void)
{
	SPI_Initialize();				//Initialize SPI peripheral
	TFT_Initialize();
	I2C_Initialize(CAP1203ADDR);
	
    CAP1203_Initialize();
	
	unsigned char button = 0x00;
	
	#ifdef __DEBUG__
		int id = CAP1203_ReadID();							//Read ID of Capacitive touch controller 
		printf("Chip ID: 0x%04X. \r\n",id);
	#endif
	
	TFT_Background(WHITE);
	TFT_Circle(80,35,20,RED);
	TFT_Circle(80,80,20,GREEN);
	TFT_Circle(80,125,20,BLUE);
	  
	while(1)
	{
		button = CAP1203_ReadPressedButton();
			switch(button)
			{
				case 1:
					TFT_Disk(80,125,10,BLUE);
					printf("Button B1 pressed.\r\n");
					break;
				case 2:
					TFT_Disk(80,80,10,GREEN);
					printf("Button B2 pressed.\r\n");
					break;					
				case 3:
					TFT_Disk(80,35,10,RED);
					printf("Button B3 pressed.\r\n");
					break;				
				default:
					TFT_Circle(80,35,20,RED);				//Paint two circles for an annular ring
					TFT_Circle(80,80,20,GREEN);
					TFT_Circle(80,125,20,BLUE);	
					TFT_Circle(80,35,19,RED);
					TFT_Circle(80,80,19,GREEN);
					TFT_Circle(80,125,19,BLUE);
					
					TFT_Disk(80,35,10,WHITE);				//Clear interior
					TFT_Disk(80,80,10,WHITE);
					TFT_Disk(80,125,10,WHITE);
					break;
			}	
		delay_ms(100);		
    }
    return 0;
}
Esempio n. 4
0
void initializeEverything()
{
	int i, j, k;
	uint32_t increment;
	LCDInitialize();
	SPI_Initialize();
	//* setup oscs
	initializeOscillators();
	// Setup the keyboard usb
	SynthStationUsbInitialize();
	//calculate the note frequencies
		WaveformTablesInitialize();
		
	/** Calculate frequency increments */
	for(i = 0; i < 120; i++)
	{
		increment = noteTable[i];
		noteTable[i] = getIncrement(increment);
	}
	
	/** Initialize sequencer layerw */
	
	for(i = 0; i < 8; i++)
	{
		for(j = 0; j < SEQUENCER_STEPS; j++)
		{
				synthLayers[i].sequenceNotes[j] = 0xFFFF;
		}
		synthLayers[i].waveType = currentSelectedWaveForm;
	}
	
	synthLayers[0].layerFlags |= LAYER_FLAGS_ENABLED;
	synthLayers[1].layerFlags |= LAYER_FLAGS_ENABLED;
	
	noteListHead = (noteListItem *)malloc(sizeof(noteListItem));
	noteListHead->pNextItem = NULL;
	noteListHead->pNote = NULL;
	noteListTail = noteListHead;
		
	currentSelectedMode = SYNTH_RECORDING;
	setBPM(DEFAULT_BPM);
	
	BEAT_LED_START_DD = BEAT_LED_DD = 1;
	BEAT_LED_START = BEAT_LED = 0;
	
	//listTest();
	
}
Esempio n. 5
0
int main(void)
{
	
	char str[20];
	unsigned int channel0;
	unsigned int channel1;
	float lux;
	
	signal(SIGINT, sigint_handler);		//Install signal handler for user interrupt (CTRL-C)
	
	SPI_Initialize();					//Initialize SPI peripheral
	TFT_Initialize();
	
	I2C_Initialize(APDS9300ADDR);		//Initialize I2C and setup chip address	
	AL_Initialize();					//Setup Ambient light sensor

	Image_t LampOn = {_acLampON,100,100};
	TFT_Background(WHITE);
	
	TFT_DisplayImage(&LampOn,5,5);
	
    while(programRunning)
    { 	 
		channel0 = AL_ReadChannel(CH0);		//Take a reading from channel one
		channel1 = AL_ReadChannel(CH1);		//Take a reading from channel two	
        lux = AL_Lux(channel0,channel1);
		sprintf(str, "%3.2f Lx ", lux);
		TFT_PrintString(10,140,RED,WHITE,str,2);
		delay_ms(1000);		
    }
	
	SPI_Close();
	bcm2835_close();
	
    return 0;
}
Esempio n. 6
0
uint8_t NRF24L01_Init(uint8_t channel, uint8_t payload_size)
{
    /* Initialize SPI */
	SPI_Initialize();

	/* Initialize CE and CSN pins */
	NRF24L01_InitPins();

	/* Max payload is 32bytes */
	if (payload_size > 32) {
		payload_size = 32;
	}

	/* Fill structure */
	NRF24L01_Struct.Channel = !channel; /* Set channel to some different value for NRF24L01_SetChannel() function */
	NRF24L01_Struct.PayloadSize = payload_size;
	NRF24L01_Struct.OutPwr = NRF24L01_OutputPower_0dBm;
	NRF24L01_Struct.DataRate = NRF24L01_DataRate_2M;

	/* Reset nRF24L01+ to power on registers values */
	NRF24L01_SoftwareReset();

	/* Channel select */
	NRF24L01_SetChannel(channel);

	/* Set pipeline to max possible 32 bytes */
	NRF24L01_WriteRegister(NRF24L01_REG_RX_PW_P0, NRF24L01_Struct.PayloadSize); // Auto-ACK pipe
	NRF24L01_WriteRegister(NRF24L01_REG_RX_PW_P1, NRF24L01_Struct.PayloadSize); // Data payload pipe
	NRF24L01_WriteRegister(NRF24L01_REG_RX_PW_P2, NRF24L01_Struct.PayloadSize);
	NRF24L01_WriteRegister(NRF24L01_REG_RX_PW_P3, NRF24L01_Struct.PayloadSize);
	NRF24L01_WriteRegister(NRF24L01_REG_RX_PW_P4, NRF24L01_Struct.PayloadSize);
	NRF24L01_WriteRegister(NRF24L01_REG_RX_PW_P5, NRF24L01_Struct.PayloadSize);

	/* Set RF settings (2mbps, output power) */
	NRF24L01_SetRF(NRF24L01_Struct.DataRate, NRF24L01_Struct.OutPwr);

	/* Config register */
	NRF24L01_WriteRegister(NRF24L01_REG_CONFIG, NRF24L01_CONFIG);

	/* Enable auto-acknowledgment for all pipes */
	NRF24L01_WriteRegister(NRF24L01_REG_EN_AA, 0x3F);

	/* Enable RX addresses */
	NRF24L01_WriteRegister(NRF24L01_REG_EN_RXADDR, 0x3F);

	/* Auto retransmit delay: 1000 (4x250) us and Up to 15 retransmit trials */
	NRF24L01_WriteRegister(NRF24L01_REG_SETUP_RETR, 0x4F);

	/* Dynamic length configurations: No dynamic length */
	NRF24L01_WriteRegister(NRF24L01_REG_DYNPD, (0 << NRF24L01_DPL_P0) | (0 << NRF24L01_DPL_P1) | (0 << NRF24L01_DPL_P2) | (0 << NRF24L01_DPL_P3) | (0 << NRF24L01_DPL_P4) | (0 << NRF24L01_DPL_P5));

	/* Clear FIFOs */
	NRF24L01_FLUSH_TX(NRF24L01_SPI);
	NRF24L01_FLUSH_RX(NRF24L01_SPI);

	/* Clear interrupts */
	NRF24L01_CLEAR_INTERRUPTS;

	/* Go to RX mode */
	NRF24L01_PowerUpRx();

	/* Return OK */
	return 1;
}
Esempio n. 7
0
int main(void)
{

	SPI_Initialize();				//Initialize SPI peripheral
	TFT_Initialize();

	char texty[] = "Sensorian-123";

    while(1)
    {
		TFT_Background(WHITE);
		TFT_SetRotation(PORTRAIT);		//Portrait mode 
		TFT_VerticalLine(5,5,90,BLUE);
		TFT_PrintString(10,80,FOREGROUND,BACKGROUND,texty,1);
		delay_ms(DELAY);   
		
		TFT_Background(WHITE);
		TFT_SetRotation(PORTRAIT_INV);		//Portrait mode 
		TFT_VerticalLine(5,5,90,GREEN);
		TFT_PrintString(10,80,RED,BACKGROUND,texty,1);
		delay_ms(DELAY);   
		
		TFT_Background(WHITE);
		TFT_SetRotation(PORTRAIT_REF);			//Portrait mode reflected 
		TFT_VerticalLine(5,5,90,YELLOW);
		TFT_PrintString(10,80,GREEN,BACKGROUND,texty,1);
		delay_ms(DELAY);   
		
		TFT_Background(WHITE);
		TFT_SetRotation(PORTRAIT_INV_REF);		
		TFT_VerticalLine(5,5,90,RED);			//Portrait mode reflected
		TFT_PrintString(10,80,PURPLE,BACKGROUND,texty,1);
		delay_ms(DELAY);   
		
		TFT_Background(WHITE);
		TFT_SetRotation(LANDSCAPE);			//Landscape mode 
		TFT_VerticalLine(5,5,80,GRAY1);
		TFT_PrintString(10,80,GREEN,BACKGROUND,texty,1);
		delay_ms(DELAY);   
		
		TFT_Background(WHITE);
		TFT_SetRotation(LANDSCAPE_REF);				//Landscape mode  reflected
		TFT_VerticalLine(5,5,80,PURPLE);
		TFT_PrintString(10,80,PURPLE,BACKGROUND,texty,1);
		delay_ms(DELAY);   
		
		TFT_Background(WHITE);
		TFT_SetRotation(LANDSCAPE_INV);			//Landscape mode inverted
		TFT_VerticalLine(5,5,80,NAVY);
		TFT_PrintString(10,80,RED,BACKGROUND,texty,1);
		delay_ms(DELAY);   
		
		TFT_Background(WHITE);
		TFT_SetRotation(LANDSCAPE_INV_REF);
		TFT_VerticalLine(5,5,80,PURPLE);
		TFT_PrintString(10,80,FOREGROUND,BACKGROUND,texty,1);	//Landscape mode inverted reflected
		delay_ms(DELAY);     
    }
	
	SPI_Close();

    return 0;
}
Esempio n. 8
0
/**
 * @brief Prepares the TFT LCD and its SPI bus for use, clearing the screen to black as well
 * @return none
 */
void TFT_Setup()
{
    SPI_Initialize(); //Prepare the SPI bus for use by the LCD
    TFT_Initialize(); //Prepare the TFT LCD for use
    TFT_Background(BLACK); //Clear the screen to Black
}
Esempio n. 9
0
/**@fn 		char Encoder_Initialize_SPI()
 *@brief	Initializes the AVR's hardware SPI to communicate with the LS7366R encoder chip
 */
char Encoder_Initialize_SPI()
{
	SPI_Initialize(MSTRSEL,MSBF,CPLLH,CPHSL);
	return 1;
}
Esempio n. 10
0
void SYSTEM_Initialize(void) {
    OSCILLATOR_Initialize();
    PIN_MANAGER_Initialize();
    SPI_Initialize();
    TMR2_Initialize();
}