/* Initializes pin muxing for I2C interface - note that SystemInit() may
   already setup your pin muxing at system startup */
static void Init_I2C_PinMux(void)
{
#if defined(BOARD_NXP_LPCXPRESSO_1549)
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 22, IOCON_DIGMODE_EN | I2C_MODE);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 23, IOCON_DIGMODE_EN | I2C_MODE);
	Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SCL);
	Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA);
#else
	/* Configure your own I2C pin muxing here if needed */
#error "No I2C Pin Muxing defined for this example"
#endif
}
Exemplo n.º 2
0
/**
 * Configure the pinmuxing for the MultiSensor board.
 *
 * only the special functions are set here, default the pins are gpio.
 */
void PINMUX_Init()
{
	/* Enable the clock to the Switch Matrix */
	Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);

	/* DISconnect the XTALIN and XTALOUT signals to port pins(P0.8, P0.9), as these will be used for gpio purposes */
	/* these are fixed location pins */
	Chip_SWM_FixedPinEnable(SWM_FIXED_XTALIN, false);
	Chip_SWM_FixedPinEnable(SWM_FIXED_XTALOUT, false);

	/* connect the fixed reset_n pin to P0.5 */
	Chip_SWM_EnableFixedPin(SWM_FIXED_RST);

	/* Connect the I2C_SDA0 and I2C_SCL0 signals to port pins(P0.10, P0.11) */
	/* these are fixed location pins */
	Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA);
	Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SCL);

	/* Connect the ADC0 (P0.7) and ADC1 (P0.6) */
	/* these are fixed location pins */
	Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0);
	Chip_SWM_EnableFixedPin(SWM_FIXED_ADC1);

	/* Connect the USART0 TX & RX signals to port pins(P0.16, P0.26) */
	/* these are movable location pins */
	Chip_SWM_MovablePinAssign(SWM_U0_TXD_O, 16);
	Chip_SWM_MovablePinAssign(SWM_U0_RXD_I, 26);

	/* Connect the USART1 RX signal to port pins(P0.25) */
	/* these are movable location pins */
	Chip_SWM_MovablePinAssign(SWM_U1_RXD_I, 25);


	/* Connect the SCT OUTPUT 1,2,3 (PWM : RGB)  signal to port pin(P0.1, P0.9, P0.8) --> this is the RGB led*/
	/* these are movable location pins */
	Chip_SWM_MovablePinAssign(SWM_SCT_OUT1_O, 1);
	Chip_SWM_MovablePinAssign(SWM_SCT_OUT2_O, 9);
	Chip_SWM_MovablePinAssign(SWM_SCT_OUT3_O, 8);

	/* make sure to disable fixed pin functionality for HUMIDITY dht22 data pin */
	Chip_SWM_DisableFixedPin(SWM_FIXED_ADC10);
	//Chip_SWM_MovablePinAssign(SWM_SCT_IN1_I, 13);


	/* Disable the clock to the Switch Matrix to save power */
	Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
}
Exemplo n.º 3
0
/* ACMP Pin mux function - note that SystemInit() may already setup your
   pin muxing at system startup */
static void Init_ACMP_PinMux(void)
{
#if defined(BOARD_NXP_LPCXPRESSO_1549)
	/* Disables pullups/pulldowns and disable digital mode */
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 9, (IOCON_MODE_INACT | IOCON_ADMODE_EN));

	/* Assign ADC1_1 to PIO0_9 via SWM (fixed pin) */
	Chip_SWM_EnableFixedPin(SWM_FIXED_ADC1_1);
#else
	/* Configure your own ACMP pin muxing here if needed */
#warning "No ACMP pin muxing defined"
#endif
}
Exemplo n.º 4
0
TempSensDig::TempSensDig(int deviceNumber, uint32_t speed) {
	if(deviceNumber == 0) {
		device = LPC_I2C0;
		Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 22, IOCON_DIGMODE_EN | I2C_MODE);
		Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 23, IOCON_DIGMODE_EN | I2C_MODE);
		Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SCL);
		Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA);
	}
	else {
		// currently we support only I2C number 0
	}
	/* Enable I2C clock and reset I2C peripheral - the boot ROM does not
	   do this */
	Chip_I2C_Init(device);

	/* Setup clock rate for I2C */
	Chip_I2C_SetClockDiv(device, I2C_CLK_DIVIDER);

	/* Setup I2CM transfer rate */
	Chip_I2CM_SetBusSpeed(device, speed);

	/* Enable Master Mode */
	Chip_I2CM_Enable(device);
}
Exemplo n.º 5
0
/**
 * @brief	main routine for ADC example
 * @return	Function should not exit
 */
int main(void)
{
	SystemCoreClockUpdate();
	Board_Init();
	DEBUGSTR("ADC ROM sequencer demo\r\n");

	/* Power up, enable clock and reset ADC0 */
	Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_ADC0_PD);
	Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_ADC0);
	Chip_SYSCTL_PeriphReset(RESET_ADC0);
	/* Power up, enable clock and reset ADC1 */
	Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_ADC1_PD);
	Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_ADC1);
	Chip_SYSCTL_PeriphReset(RESET_ADC1);
	/* Power up the internal temperature sensor */
	Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_TS_PD);

#if defined(BOARD_NXP_LPCXPRESSO_1549)
	/* Disables pullups/pulldowns and disable digital mode */
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 9, (IOCON_MODE_INACT | IOCON_ADMODE_EN));

	/* Assign ADC1_1 to PIO0_9 via SWM (fixed pin) */
	Chip_SWM_EnableFixedPin(SWM_FIXED_ADC1_1);

#else
#warning "No ADC setup for this example"
#endif
	/* Initialize ROM API base address for ADC */
	pAdcApi = LPC_ADCD_API;
	size_in_bytes = pAdcApi->adc_get_mem_size();
	if (size_in_bytes / 4 > RAMBLOCK_H) {
		/* Adjust RAMBLOCK size in this case */
		return 1;
	}
	/* ADC Handle Setup*/
	adc_handle[0] = pAdcApi->adc_setup(LPC_ADC0_BASE, (uint8_t *) start_of_ram_block[0]);
	adc_handle[1] = pAdcApi->adc_setup(LPC_ADC1_BASE, (uint8_t *) start_of_ram_block[1]);
	/* ADC0 Config */
	adc_cfg[0].system_clock = SystemCoreClock;	/* System clock */
	adc_cfg[0].adc_clock = 500000;	/* ADC clock set to 500KHz for calibration*/
	/* ADC1 Config */
	adc_cfg[1].system_clock = SystemCoreClock;	/* System clock */
	adc_cfg[1].adc_clock = 500000;	/* ADC clock set to 500KHz for calibration*/
	pAdcApi->adc_calibration(adc_handle[0], &adc_cfg[0]);
	pAdcApi->adc_calibration(adc_handle[1], &adc_cfg[1]);

	/* ADC0 Config for Init */
	adc_cfg[0].system_clock = SystemCoreClock;	/* System clock */
	adc_cfg[0].adc_clock = ADC_CLOCK_RATE;	/* ADC clock */
	adc_cfg[0].async_mode = 0;	/* Synchronous mode */
	adc_cfg[0].tenbit_mode = 0;	/* 12 Bit ADC mode */
	adc_cfg[0].lpwr_mode = 0;	/* Disable low power mode */
	adc_cfg[0].input_sel = ADC_INSEL_TS;
	adc_cfg[0].seqa_ctrl = (ADC_SEQ_CTRL_CHANSEL(0) | ADC_SEQ_CTRL_MODE_EOS);
	adc_cfg[0].channel_num = 1;	/* Channel number is one higher than the maximum channel number used */
	/* ADC1 Config for Init */
	adc_cfg[1].system_clock = SystemCoreClock;	/* System clock */
	adc_cfg[1].adc_clock = ADC_CLOCK_RATE;	/* ADC clock */
	adc_cfg[1].async_mode = 0;	/* Synchronous mode */
	adc_cfg[1].tenbit_mode = 0;	/* 12 Bit ADC mode */
	adc_cfg[1].lpwr_mode = 0;	/* Disable low power mode */
	adc_cfg[1].seqa_ctrl = (ADC_SEQ_CTRL_CHANSEL(BOARD_ADC_CH) | ADC_SEQ_CTRL_MODE_EOS);
	adc_cfg[1].thrsel = 0;
	adc_cfg[1].thr0_low = ((1 * 0xFFF) / 4) << 4;
	adc_cfg[1].thr0_high = ((3 * 0xFFF) / 4) << 4;
	adc_cfg[1].thcmp_en = ADC_INTEN_CMP_ENABLE(ADC_INTEN_CMP_CROSSTH, BOARD_ADC_CH);
	adc_cfg[1].channel_num = BOARD_ADC_CH + 1;	/* Channel number is one higher than the maximum channel number used */
	pAdcApi->adc_init(adc_handle[0], &adc_cfg[0]);
	pAdcApi->adc_init(adc_handle[1], &adc_cfg[1]);
	
	/* When using ADC ROM API's lower the priority of ADC Sequence completion interrupt when compared to the threshold interrupt*/
	NVIC_SetPriority(ADC1_SEQA_IRQn, 1);
	/* Enable related ADC NVIC interrupts */
	NVIC_EnableIRQ(ADC0_SEQA_IRQn);
	NVIC_EnableIRQ(ADC1_SEQA_IRQn);
	NVIC_EnableIRQ(ADC1_THCMP);

	/* This example uses the periodic sysTick to manually trigger the ADC,
	   but a periodic timer can be used in a match configuration to start
	   an ADC sequence without software intervention. */
	SysTick_Config(Chip_Clock_GetSysTickClockRate() / TICKRATE_HZ);

	/* Endless loop */
	while (1) {
		/* Sleep until something happens */
		__WFI();

		if (threshold1Crossed) {
			threshold1Crossed = false;
			DEBUGSTR("********ADC1 threshold event********\r\n");
		}

		/* Is a conversion sequence complete? */
		if (sequence0Complete) {
			sequence0Complete = false;
			showValudeADC(LPC_ADC0);
		}
		if (sequence1Complete) {
			sequence1Complete = false;
			showValudeADC(LPC_ADC1);
		}
	}

	/* Should not run to here */
	return 0;
}