Esempio n. 1
0
/**
 * @brief	Main routine for I2C example
 * @return	Function should not exit
 */
int main(void)
{
	/* Generic Initialization */
	SystemCoreClockUpdate();
	Board_Init();

	Board_LED_Set(0, false);

	/* Setup I2C at the board level (usually pin muxing) */
	Init_I2C_PinMux();

	/* Allocate I2C handle, setup I2C rate, and initialize I2C
	   clocking */
	setupI2CSlave();

	/* Enable the interrupt for the I2C */
	NVIC_EnableIRQ(I2C_IRQn);

	/* Setup I2C receive slave mode - this will setup a
	   non-blocking I2C mode which will be handled via the I2C interrupt */
	readI2CSlave();	/* From master first */

	/* I2C slave handler loop - wait for requests from master and
	   receive or send data */
	while (1) {
		/* Sleep while waiting for I2C master requests */
		__WFI();

		/* All I2C slave processing is performed in the I2C IRQ
		   handler, so there is nothing to really do here */
	}

	return 0;
}
	void i2c_setup(void)
{
	/* Setup I2C pin muxing */
	Init_I2C_PinMux();

	/* Setup I2C, master, and slave */
	setupI2CMaster();
  setupI2CSlave();

	/* Enable the interrupt for the I2C */
	NVIC_EnableIRQ(LPC_IRQNUM);
		
	xI2cSemaphore =xSemaphoreCreateBinary();
	

	DEBUGOUT(" I2C slaves are ready\r\n");
}