Пример #1
0
void init_rgb_pwm(uint8_t _gpio_r, uint8_t _gpio_g, uint8_t _gpio_b, uint8_t _gpio_i){
	timer_init();

	MSS_GPIO_config((gpio_r_i = _gpio_r), MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_POSITIVE);
	MSS_GPIO_config((gpio_g_i = _gpio_g), MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_POSITIVE);
	MSS_GPIO_config((gpio_b_i = _gpio_b), MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_POSITIVE);
	MSS_GPIO_config((gpio_i_i = _gpio_i), MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_POSITIVE);

	MSS_GPIO_enable_irq(_gpio_r);
	MSS_GPIO_enable_irq(_gpio_g);
	MSS_GPIO_enable_irq(_gpio_b);
	MSS_GPIO_enable_irq(_gpio_i);

	// add the timer peripherals to the timer module
	red_timer_id   = add_timer(TIMER_RED);
	green_timer_id = add_timer(TIMER_GREEN);
	blue_timer_id  = add_timer(TIMER_BLUE);
	pulse_timer_id = add_timer(TIMER_PULSE);

	// all colors overflow at their max pwm value
	timer_setOverflowVal(red_timer_id, 1000000);
	timer_setOverflowVal(blue_timer_id, 1000000);
	timer_setOverflowVal(green_timer_id, 1000000);

	// pulse uses overflow only
	//timer_enable_allInterrupts(pulse_timer_id);
	timer_enable_overflowInt(pulse_timer_id);
	timer_disable_compareInt(pulse_timer_id);

	// colors require overflow and compare registers
	timer_enable_allInterrupts(red_timer_id);
	timer_enable_allInterrupts(blue_timer_id);
	timer_enable_allInterrupts(green_timer_id);

	timer_enable_compareInt(red_timer_id);
	timer_enable_compareInt(blue_timer_id);
	timer_enable_compareInt(green_timer_id);

	timer_enable_overflowInt(red_timer_id);
	timer_enable_overflowInt(blue_timer_id);
	timer_enable_overflowInt(green_timer_id);

	timer_enable(red_timer_id);
	timer_enable(green_timer_id);
	timer_enable(blue_timer_id);
	//timer_enable(pulse_timer_id);


	// don't start the colors until set_brightness is called
}
Пример #2
0
static void prvSetupHardware( void )
{
	SystemCoreClockUpdate();

	/* Disable the Watch Dog Timer */
	MSS_WD_disable( );

	/* Initialise the GPIO */
	MSS_GPIO_init();

	/* Set up GPIO for the LEDs. */
    MSS_GPIO_config( MSS_GPIO_0 , MSS_GPIO_OUTPUT_MODE );
    MSS_GPIO_config( MSS_GPIO_1 , MSS_GPIO_OUTPUT_MODE );
    MSS_GPIO_config( MSS_GPIO_2 , MSS_GPIO_OUTPUT_MODE );
    MSS_GPIO_config( MSS_GPIO_3 , MSS_GPIO_OUTPUT_MODE );
    MSS_GPIO_config( MSS_GPIO_4 , MSS_GPIO_OUTPUT_MODE );
    MSS_GPIO_config( MSS_GPIO_5 , MSS_GPIO_OUTPUT_MODE );
    MSS_GPIO_config( MSS_GPIO_6 , MSS_GPIO_OUTPUT_MODE );
    MSS_GPIO_config( MSS_GPIO_7 , MSS_GPIO_OUTPUT_MODE );

    /* All LEDs start off. */
    ulGPIOState = 0xffffffffUL;
    MSS_GPIO_set_outputs( ulGPIOState );

	/* Setup the GPIO and the NVIC for the switch used in this simple demo. */
	NVIC_SetPriority( GPIO8_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( GPIO8_IRQn );
    MSS_GPIO_config( MSS_GPIO_8, MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_NEGATIVE );
    MSS_GPIO_enable_irq( MSS_GPIO_8 );
}
Пример #3
0
void rfid_init() {
	/* Initialize CoreUARTapb for bar code scanner settings */
	UART_init(&g_rfid_uart, RFID_UART_BASE_ADDR, RFID_BAUD_VALUE, DATA_8_BITS | NO_PARITY);

	/* Initialize the MSS GPIO & GPIO_0 Interrupt */
    MSS_GPIO_config( MSS_GPIO_1, MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_BOTH );
    MSS_GPIO_enable_irq( MSS_GPIO_1 );
    NVIC_EnableIRQ(GPIO1_IRQn);

	vSemaphoreCreateBinary( rfid_top_sem );
	_rfid_init_done = 1;
}
Пример #4
0
void rfid_task() {
	for(;;) {
		char temp;
		rfid_t msg;
		int bytes_read;
		int i;
		// Wait for wakeup from interrupt
		vTaskDelay(portTICK_RATE_MS * 100);
		xSemaphoreTake(rfid_top_sem, portMAX_DELAY);

		/* Wait until we get a 4C (start of header) */
		while(1) {
			bytes_read = UART_get_rx(&g_rfid_uart, (unsigned char*)&temp, 1);
			if(bytes_read == 0) {
				break;
			} else if(temp == 0x4C) {

				bytes_read = UART_get_rx(&g_rfid_uart, (unsigned char*)&temp, 1);
				if(bytes_read == 0 || temp != 0x57) {
					/* Good read */
					break;
				}

				/* Don't care about the transponder type */
				bytes_read = UART_get_rx(&g_rfid_uart, (unsigned char*)&temp, 1);

				/* RXRDY is high when data is available in the receive data buffer/FIFO.
				This bit is cleared by reading the Receive Data Register.	 */
				bytes_read = UART_get_rx(&g_rfid_uart, (unsigned char*)&msg.data, RFID_LEN);
				if(bytes_read != RFID_LEN) {
					break;
				}

				msg.data[RFID_MSG_LEN-1] = '\0';

				/* Pass ID to control unit */
				xQueueSendToBack(g_rfid_queue, &msg, 0);
				vTaskDelay(portTICK_RATE_MS * 1000); //Ignore rfid for a short bit

				/* Break out of while loop */
				break;
			}
		}

		/* Clear the buffer until it's empty */
		while((bytes_read = UART_get_rx(&g_rfid_uart, (unsigned char*)&temp, 1)) > 0);

		MSS_GPIO_enable_irq(MSS_GPIO_1);
	}
}
Пример #5
0
void MY_GPIO_init(void) {
	// Initialize MSS GPIOs.
	void MSS_GPIO_init(void);

	// Configure the MSS GPIO output pins
	MSS_GPIO_config(MSS_GPIO_0, MSS_GPIO_OUTPUT_MODE );
	MSS_GPIO_config(MSS_GPIO_1, MSS_GPIO_OUTPUT_MODE );
	MSS_GPIO_config(MSS_GPIO_2, MSS_GPIO_OUTPUT_MODE );
	MSS_GPIO_config(MSS_GPIO_3, MSS_GPIO_OUTPUT_MODE );
	MSS_GPIO_config(MSS_GPIO_4, MSS_GPIO_OUTPUT_MODE );
	MSS_GPIO_config(MSS_GPIO_5, MSS_GPIO_OUTPUT_MODE );
	MSS_GPIO_config(MSS_GPIO_6, MSS_GPIO_OUTPUT_MODE );
	MSS_GPIO_config(MSS_GPIO_7, MSS_GPIO_OUTPUT_MODE );

	// Configure the MSS GPIO input pins + configure interrupt mode (rising)
	MSS_GPIO_config(MSS_GPIO_8, MSS_GPIO_INPUT_MODE
			| MSS_GPIO_IRQ_EDGE_POSITIVE );
	MSS_GPIO_config(MSS_GPIO_9, MSS_GPIO_INPUT_MODE
			| MSS_GPIO_IRQ_EDGE_POSITIVE );

	// Enable the input pin interrupts in the MSS
    MSS_GPIO_enable_irq( MSS_GPIO_8 );
    MSS_GPIO_enable_irq( MSS_GPIO_9 );
}
Пример #6
0
static void prvSetupHardware( void )
{
	SystemCoreClockUpdate();
	
	/* Disable the Watch Dog Timer */
	MSS_WD_disable( );

	/* Configure the GPIO for the LEDs. */
	vParTestInitialise();
	
	/* ACE Initialization */
	ACE_init();

	/* Setup the GPIO and the NVIC for the switch used in this simple demo. */
	NVIC_SetPriority( GPIO8_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( GPIO8_IRQn );
    MSS_GPIO_config( MSS_GPIO_8, MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_NEGATIVE );
    MSS_GPIO_enable_irq( MSS_GPIO_8 );
}
Пример #7
0
void Yellowstone_Init(void)
{
	// MSS_GPIO_init( );
	MSS_GPIO_config( MSS_GPIO_0, MSS_GPIO_OUTPUT_MODE );
	MSS_GPIO_set_output( MSS_GPIO_0, 0 );

	// Initialize SPI master
	MSS_SPI_init( &g_mss_spi0 );
	MSS_SPI_configure_master_mode
	(
		&g_mss_spi0,
		MSS_SPI_SLAVE_0,
		MSS_SPI_MODE0,
		MSS_SPI_PCLK_DIV_128,
		spi_frame_size
	);
	MSS_SPI_enable( &g_mss_spi0 );

	MSS_GPIO_config ( MSS_GPIO_SPI_0_IT, MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_LEVEL_HIGH );
	MSS_GPIO_enable_irq( MSS_GPIO_SPI_0_IT );
	NVIC_EnableIRQ( MSS_GPIO_SPI_0_IT_IRQn );
}