int main(void) { pin_setup(); enable_1v8_power(); cpu_clock_init(); scs_dwt_cycle_counter_enabled(); systick_setup(); gpio_set(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LEDs on */ while (1) { gpio_set(PORT_LED1_3, (PIN_LED1)); /* LED1 on */ gpio_set(PORT_LED1_3, (PIN_LED2)); /* LED2 on */ gpio_set(PORT_LED1_3, (PIN_LED3)); /* LED3 on */ sys_tick_wait_time_ms(500); gpio_clear(PORT_LED1_3, (PIN_LED3)); /* LED3 off */ gpio_clear(PORT_LED1_3, (PIN_LED2)); /* LED2 off */ gpio_clear(PORT_LED1_3, (PIN_LED1)); /* LED1 off */ sys_tick_wait_time_ms(500); } return 0; }
int main(void) { pin_setup(); enable_1v8_power(); cpu_clock_init(); scs_dwt_cycle_counter_enabled(); systick_setup(); led_on(LED1); led_on(LED2); led_on(LED3); while (1) { led_on(LED1); led_on(LED2); led_on(LED3); sys_tick_wait_time_ms(500); led_off(LED1); led_off(LED2); led_off(LED3); sys_tick_wait_time_ms(500); } return 0; }
int main(void) { const uint32_t freq = 2441000000U; pin_setup(); gpio_set(PORT_EN1V8, PIN_EN1V8); /* 1V8 on */ cpu_clock_init(); ssp1_init(); gpio_set(PORT_LED1_3, (PIN_LED1)); /* LED1 on */ ssp1_set_mode_max2837(); max2837_setup(); rffc5071_setup(); gpio_set(PORT_LED1_3, (PIN_LED2)); /* LED2 on */ max2837_set_frequency(freq); max2837_start(); max2837_tx(); gpio_set(PORT_LED1_3, (PIN_LED3)); /* LED3 on */ while (1); max2837_stop(); return 0; }
int main(void) { int i; uint8_t buf[515]; pin_setup(); enable_1v8_power(); cpu_clock_init(); /* program test data to SPI flash */ for (i = 0; i < 515; i++) buf[i] = (i * 3) & 0xFF; w25q80bv_setup(); w25q80bv_chip_erase(); w25q80bv_program(790, 515, &buf[0]); /* blink LED1 and LED3 */ while (1) { gpio_set(PORT_LED1_3, (PIN_LED1|PIN_LED3)); /* LEDs on */ for (i = 0; i < 8000000; i++) /* Wait a bit. */ __asm__("nop"); gpio_clear(PORT_LED1_3, (PIN_LED1|PIN_LED3)); /* LED off */ for (i = 0; i < 8000000; i++) /* Wait a bit. */ __asm__("nop"); } return 0; }
int main(void) { int i; pin_setup(); /* Blink LED1/2/3 on the board. */ while (1) { led_on(LED1); led_off(LED2); led_on(LED3); led_off(LED4); for (i = 0; i < 2000000; i++) /* Wait a bit. */ __asm__("nop"); led_off(LED1); led_on(LED2); led_off(LED3); led_on(LED4); for (i = 0; i < 2000000; i++) /* Wait a bit. */ __asm__("nop"); } return 0; }
int main(void) { cpu_clock_init(); cpu_clock_pll1_max_speed(); rtc_init(); pin_setup(); /* Blink LED1/2/3/4 on the board. */ while (1) { led_on(LED1); led_off(LED2); led_on(LED3); led_off(LED4); delay(5000000); led_off(LED1); led_on(LED2); led_off(LED3); led_on(LED4); delay(5000000); } return 0; }
int main(void) { int i; pin_setup(); /* enable all power supplies */ enable_1v8_power(); #ifdef HACKRF_ONE enable_rf_power(); #endif /* Blink LED1/2/3 on the board and Read BOOT0/1/2/3 pins. */ while (1) { boot0 = BOOT0_STATE; boot1 = BOOT1_STATE; boot2 = BOOT2_STATE; boot3 = BOOT3_STATE; gpio_set(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LEDs on */ for (i = 0; i < 2000000; i++) /* Wait a bit. */ __asm__("nop"); gpio_clear(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LED off */ for (i = 0; i < 2000000; i++) /* Wait a bit. */ __asm__("nop"); } return 0; }
int main(void) { pin_setup(); interrupt_setup(); while(1) { } }
int main(void) { pin_setup(); register_setup(); sei(); myMenu.MenuStart(); while (1) { } }
int main(void) { pin_setup(); pwm_setup(); while(1) { /* Placeholder for code to utilize the microcontroller */ } return 0; }
int main(void) { pin_setup(); enable_1v8_power(); cpu_clock_init(); ssp1_init(); gpio_set(PORT_LED1_3, PIN_LED1); //test_sgpio_sliceA_D(); test_sgpio_interface(); //test_sgpio_all_slices(); while(1); return 0; }
int handle_packet_pin_function(unsigned char length, unsigned char *data) { int s; // check if length matches for packet-data if(length != 2) { send_status_packet(PACKET_RETURN_INAVLID_DATA); return PACKET_STAT_ERR_DATA; } packet_data_in_pin_function *pd = (packet_data_in_pin_function *)&data[0]; if((s = pin_setup(pd->pin, pd->function)) != PACKET_STAT_OK) { send_status_packet(PACKET_RETURN_INVALID_PIN_COMMAND); } else { send_status_packet(PACKET_RETURN_ACK); } return s; }
int main(void) { pin_setup(); enable_1v8_power(); cpu_clock_init(); ssp1_init(); CGU_BASE_PERIPH_CLK = (CGU_BASE_CLK_AUTOBLOCK | (CGU_SRC_PLL1 << CGU_BASE_CLK_SEL_SHIFT)); CGU_BASE_APB1_CLK = (CGU_BASE_CLK_AUTOBLOCK | (CGU_SRC_PLL1 << CGU_BASE_CLK_SEL_SHIFT)); gpio_set(PORT_LED1_3, PIN_LED1); //test_sgpio_sliceA_D(); test_sgpio_interface(); //test_sgpio_all_slices(); while(1); return 0; }
int main(void) { clock_init(); pin_reserve(PIN_1_1); pin_reserve(PIN_1_2); serial_init(9600); cio_print("** ROCKETuC - librocketcore PIN test **\n\r"); dump_regs("initial"); // invalid port if(pin_setup(0x30, PIN_FUNCTION_OUTPUT) == PIN_STAT_ERR_INVALPORT) { cio_print("0x30 is an invalid port\n\r"); } // invalid pin if(pin_setup(0x2A, PIN_FUNCTION_OUTPUT) == PIN_STAT_ERR_INVALPIN) { cio_print("0x2A is an invalid pin\n\r"); } // P1.1 + P1.2 are reserved for UART1 if(pin_setup(PIN_1_1, PIN_FUNCTION_OUTPUT) == PIN_STAT_ERR_INVALPIN) { cio_print("0x11 is an invalid (reserved) pin\n\r"); } if(pin_setup(PIN_1_2, PIN_FUNCTION_OUTPUT) == PIN_STAT_ERR_INVALPIN) { cio_print("0x12 is an invalid (reserved) pin\n\r"); } // pins on port 2 do not support ADC int p; for(p = 0; p < 8; p++) { if(pin_setup(PIN_2_0 + p, PIN_FUNCTION_ANALOG_IN) == PIN_STAT_ERR_UNSUPFUNC) { cio_printf("0x2%i does not support ADC\n\r", p); } } // set P1.0 + P1.6 + P2.5 to output (the build in LEDs) pin_setup(PIN_1_0, PIN_FUNCTION_OUTPUT); pin_setup(PIN_1_6, PIN_FUNCTION_OUTPUT); pin_setup(PIN_2_5, PIN_FUNCTION_OUTPUT); dump_regs("p1.0+p1.6+p2.5 output"); // set P1.0 + P1.6 + P2.5 to HIGH pin_set(PIN_1_0); pin_set(PIN_1_6); pin_set(PIN_2_5); dump_regs("p1.0+p1.6+p2.5 set"); // read P1.0 + P1.6 + p2.5 states cio_printf("P1.0 is %x\n\r", pin_digital_read(PIN_1_0)); cio_printf("P1.6 is %x\n\r", pin_digital_read(PIN_1_6)); cio_printf("P2.5 is %x\n\r", pin_digital_read(PIN_2_5)); // clear P1.0 + p1.6 + p2.5 to LOW pin_clear(PIN_1_0); pin_clear(PIN_1_6); pin_clear(PIN_2_5); dump_regs("p1.0+p1.6+p2.5 clear"); // read P1.0 + P1.6 + 2.5 states cio_printf("P1.0 is %x\n\r", pin_digital_read(PIN_1_0)); cio_printf("P1.6 is %x\n\r", pin_digital_read(PIN_1_6)); cio_printf("P2.5 is %x\n\r", pin_digital_read(PIN_2_5)); // toggle P1.0 + P1.6 + P2.5 pin_toggle(PIN_1_0); pin_toggle(PIN_1_6); pin_toggle(PIN_2_5); dump_regs("p1.0+p1.6+p2.5 toggle"); // read P1.0 + P1.6 states cio_printf("P1.0 is %x\n\r", pin_digital_read(PIN_1_0)); cio_printf("P1.6 is %x\n\r", pin_digital_read(PIN_1_6)); cio_printf("P2.5 is %x\n\r", pin_digital_read(PIN_2_5)); // toggle P1.0 + P1.6 + P2.5 pin_toggle(PIN_1_0); pin_toggle(PIN_1_6); pin_toggle(PIN_2_5); dump_regs("p1.0+p1.6+p2.5 toggle"); // read P1.0 + P1.6 states cio_printf("P1.0 is %x\n\r", pin_digital_read(PIN_1_0)); cio_printf("P1.6 is %x\n\r", pin_digital_read(PIN_1_6)); cio_printf("P2.5 is %x\n\r", pin_digital_read(PIN_2_5)); // set P1.3 to input float pin_setup(PIN_1_3, PIN_FUNCTION_INPUT_FLOAT); dump_regs("p1.3 input float"); cio_print("Press button on P1.3 to continue ..."); while(pin_digital_read(PIN_1_3)) __asm__("nop"); cio_print(" OK\n\r"); // set P2.3 to input pull-down pin_setup(PIN_2_3, PIN_FUNCTION_INPUT_PULLDOWN); dump_regs("p2.3 input pull-down"); cio_print("Press button on P2.3 to continue ..."); while(!pin_digital_read(PIN_2_3)) __asm__("nop"); cio_print(" OK\n\r"); // set P2.4 to input pull-down pin_setup(PIN_2_4, PIN_FUNCTION_INPUT_PULLUP); dump_regs("p2.4 input pull-up"); cio_print("Press button on P2.4 to continue ..."); while(pin_digital_read(PIN_2_4)) __asm__("nop"); cio_print(" OK\n\r"); int pl = 0; cio_print("Press button on P1.3 for pulselength read ..."); delay(50000); pl = pin_pulselength_read(PIN_1_3); cio_printf(" OK, pl=%i\n\r", pl); cio_print("Press button on P2.3 for pulselength read ..."); delay(50000); pl = pin_pulselength_read(PIN_2_3); cio_printf(" OK, pl=%i\n\r", pl); cio_print("Press button on P2.4 for pulselength read ..."); delay(50000); pl = pin_pulselength_read(PIN_2_4); cio_printf(" OK, pl=%i\n\r", pl); pin_set(PIN_1_0); pin_clear(PIN_1_6); pin_clear(PIN_2_5); // set P1.5 to analog in int i = 0; cio_printf("setup 1.5 for analog in: %i\n\r", pin_setup(PIN_1_5, PIN_FUNCTION_ANALOG_IN)); dump_regs("p1.5 analog in"); int adcin1 = pin_analog_read(PIN_1_5); int adcin2 = 0; cio_printf("Analog read p1.5: %x\n\r", adcin1); // set P2.2 to PWM with period of 20ms and duty cycle of 7.5% cio_printf("setup 2.2 for PWM: %i\n\r", pin_setup(PIN_2_2, PIN_FUNCTION_PWM)); dump_regs("p2.2 PWM"); // only one of the two possible pins on port two are allowed to be set to PWM cio_printf("setup 2.1 for PWM: %i\n\r", pin_setup(PIN_2_1, PIN_FUNCTION_PWM)); // period pin_pwm_function(PIN_2_2, 20000); pin_pwm_control(PIN_2_2, adc2dc(adcin1)); while (1) { delay(); pin_toggle(PIN_1_0); pin_toggle(PIN_1_6); if(i++ % 2 == 0) { pin_toggle(PIN_2_5); } if(!pin_digital_read(PIN_1_3)) { pin_toggle(PIN_1_6); while(!pin_digital_read(PIN_1_3)) __asm__("nop"); } adcin2 = pin_analog_read(PIN_1_5); // only output ADC value if delta was more then 5 if(adcin2 - adcin1 > 5 || adcin1 - adcin2 > 5) { adcin1 = adcin2; cio_printf("Analog read at p1.5: %x (%i)\n\r", adcin2, adcin2); pin_pwm_control(PIN_2_2, adc2dc(adcin1)); } } return 0; }
int main(void) { pin_setup(); gpio_set(PORT_EN1V8, PIN_EN1V8); /* 1V8 on */ cpu_clock_init(); scs_dwt_cycle_counter_enabled(); systick_setup(); gpio_clear(PORT_LED1_3, (PIN_LED1)); /* LED1 off */ /* Test number of instruction per second (MIPS) slow blink ON 1s, OFF 1s */ LED1_TOGGLE(); nb_inst_per_sec[0] = test_nb_instruction_per_sec_100_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[1]= test_nb_instruction_per_sec_105_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[2]= test_nb_instruction_per_sec_110_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[3]= test_nb_instruction_per_sec_115_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[4] = test_nb_instruction_per_sec_120_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[5] = test_nb_instruction_per_sec_150_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[6] = test_nb_instruction_per_sec_200_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[7] = test_nb_instruction_per_sec_1000_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[8] = test_nb_instruction_per_sec_100_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[9]= test_nb_instruction_per_sec_105_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[10]= test_nb_instruction_per_sec_110_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[11]= test_nb_instruction_per_sec_115_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[12] = test_nb_instruction_per_sec_120_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[13] = test_nb_instruction_per_sec_150_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[14] = test_nb_instruction_per_sec_200_nop_asm(); LED1_TOGGLE(); nb_inst_per_sec[15] = test_nb_instruction_per_sec_1000_nop_asm(); LED1_TOGGLE(); /* Test finished fast blink */ while (1) { gpio_set(PORT_LED1_3, (PIN_LED1)); /* LED1 on */ gpio_set(PORT_LED1_3, (PIN_LED2)); /* LED2 on */ gpio_set(PORT_LED1_3, (PIN_LED3)); /* LED3 on */ sys_tick_wait_time_ms(250); gpio_clear(PORT_LED1_3, (PIN_LED3)); /* LED3 off */ gpio_clear(PORT_LED1_3, (PIN_LED2)); /* LED2 off */ gpio_clear(PORT_LED1_3, (PIN_LED1)); /* LED1 off */ sys_tick_wait_time_ms(250); } return 0; }
/** * Setup the ports. */ void setup() { // COMM led pin_setup(COMM, PIN_FUNCTION_OUTPUT); // READY led pin_setup(READY, PIN_FUNCTION_OUTPUT); // BUTTON pin_setup(BUTTON, PIN_FUNCTION_INPUT_PULLUP); // RESA pin_setup(RESA, PIN_FUNCTION_ANALOG_IN); // RESB pin_setup(RESB, PIN_FUNCTION_ANALOG_IN); // RESC pin_setup(RESC, PIN_FUNCTION_ANALOG_IN); // RESC pin_setup(RESD, PIN_FUNCTION_ANALOG_IN); // SLIDER-UP pin_setup(SLIDER_UP, PIN_FUNCTION_INPUT_PULLUP); pin_exti_function(SLIDER_UP, PIN_FUNCTION_EXTI_HIGHLOW, 0); // SLIDER-DOWN pin_setup(SLIDER_DWN, PIN_FUNCTION_INPUT_PULLUP); pin_exti_function(SLIDER_DWN, PIN_FUNCTION_EXTI_HIGHLOW, 0); // 1st check if sensors are available (not av. when high) pin_setup(SOUND, PIN_FUNCTION_INPUT_PULLDOWN); enable_sound = (pin_digital_read(SOUND) ? 0 : 1); if(enable_sound) { // SOUND pin_setup(SOUND, PIN_FUNCTION_INPUT_FLOAT); } pin_setup(LIGHT, PIN_FUNCTION_INPUT_PULLDOWN); // show that mcu is ready pin_set(READY); }