int ComThread::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QThread::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: switch_led((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 1: update_lcd((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< float(*)>(_a[2]))); break;
        case 2: update_mbrtu((*reinterpret_cast< char*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Пример #2
0
int main(int argc, char **argv) {

	// initialize gpio17 that is hooked up to the switch
	if(init_gpio()) {
		perror("could not initialize gpio17");
		return 1;
	}

	// S points to the switch values structure
	SWITCH_T * S = init_switch();

	while(1) {
		// read the switch values
		if(get_debounce_vals(S)) {
			perror("could not read values");
		}
		// print the state of the switch and light led accordingly
		switch_led(S);
	}

	return 0;
}
Пример #3
0
Файл: main.c Проект: anates/Cape
int main (void)
{
	/* Insert system clock initialization code here (sysclk_init()). */

	board_init();
	sysclk_init();
	ioport_init();
	/* Insert application code here, after the board has been initialized. */
	//Own variables
	bool running = true;
	bool error = false;
	uint8_t spi_counter = 0;
	//Testdata
	uint32_t testdata = 0;
	//Create command & data storage
	uint8_t commandUSART[NUMBER_CTRL_BYTES];
	uint8_t commandSPI[NUMBER_CTRL_BYTES];
	//Memory
	uint8_t write_page[EEPROM_PAGE_SIZE];
	uint8_t read_page[EEPROM_PAGE_SIZE];
	//Own inits
	init_led_pins();
	//Boot sequence initiated
	switch_led(BOOT, true);
	init_usart_driver(PIN3_bm, PIN2_bm, &USART_data_Stepper, &USARTD0);
	init_usart_driver(PIN3_bm, PIN2_bm, &USART_data_PreAmp, &USARTC0);
	//Test blinking
	for(int i = 0; i < 10; i++)
	{
		blink_led(BOOT, 100);
		blink_led(RUNNING, 50);
		blink_led(RXTX, 50);
		blink_led(FAILURE, 100);
		blink_led(RXTX, 50);
		blink_led(RUNNING, 50);
	}
	//Load Stuff from memory, no clue what I should load
	memset(read_page, 0x0, EEPROM_PAGE_SIZE);
	nvm_eeprom_read_buffer(POSITION_ADDR, read_page, EEPROM_PAGE_SIZE);
	testdata = ((uint32_t)read_page[3] << 24) | ((uint32_t)read_page[2] << 16) | ((uint32_t)read_page[1] << 8) | read_page[0];
	memset(read_page, 0x0, EEPROM_PAGE_SIZE);
	nvm_eeprom_read_buffer(SPEED_ADDR, read_page, EEPROM_PAGE_SIZE);
	//currentSpeed = ((uint32_t)read_page[0] << 24) | ((uint32_t)read_page[1] << 16) | ((uint32_t)read_page[2] << 8) | read_page[3];
	memset(read_page, 0x0, EEPROM_PAGE_SIZE);
	//Boot sequence finished
	switch_led(BOOT, false);
	//Test of data
	if(testdata != 3)
	{
		switch_led(RXTX, true);
		//testdata = 10;
	}
	else
		switch_led(RUNNING, true);	
	delay_ms(1000);
	testdata = 3;
	//End of test data;	
	if(error != true)
	{
		memset(write_page, 0x0, EEPROM_PAGE_SIZE);
		write_page[3] = testdata >> 24;
		write_page[2] = testdata >> 16;
		write_page[1] = testdata >> 8;
		write_page[0] = testdata;
		nvm_eeprom_load_page_to_buffer(write_page);
		nvm_eeprom_atomic_write_page(POSITION_ADDR);
		memset(write_page, 0x0, EEPROM_PAGE_SIZE);
		write_page[3] = testdata >> 24;
		write_page[2] = testdata >> 16;
		write_page[1] = testdata >> 8;
		write_page[0] = testdata;
		nvm_eeprom_load_page_to_buffer(write_page);
		nvm_eeprom_atomic_write_page(POSITION_ADDR);
		memset(write_page, 0x0, EEPROM_PAGE_SIZE);
		switch_led(RUNNING, false);
		switch_led(RXTX, true);
		switch_led(BOOT, true);
		//Shutdown procedure can be executed
	}