void port_main_init(void) { pin_out(&b4); pin_out(&b5); pin_out(&b6); pin_out(&b7); pin_in_pu(&l1); while (!(uart_tx_done(&uart0))); sprintf(data, "Port inited\n"); uart_tx(&uart0, data, strlen(data)); }
int main() { pin_out(&led); while(1) { _delay_us(10); pin_toggle(&led); } }
/* Reset the TCC module after breathing completes and stop interrupts */ void cancel_breathing_animation() { // Disable the TCC tcc(PWR_LED_TCC_CHAN)->CTRLA.reg = TCC_CTRLA_RESETVALUE; // Disable Boot LED TCC IRQ in the NVIC NVIC_DisableIRQ(TCC1_IRQn); // Set the PWR LED to the default high state pin_out(PIN_LED); pin_high(PIN_LED); }
int main(void) { // Setup the external LED. pin_mode(7, OUTPUT); pin_mode(8, OUTPUT); // Setup the input switch. Moving the switch to connect 4 and 5 will // pull the value of 5 low, it's normally held high by the pull-up. pin_mode(4, OUTPUT); pin_mode(5, INPUT); pin_out(5, TRUE); for (;;) { // If the switch is "off", the LED is on. if (pin_in(5)) { pin_out(7, FALSE); } else { pin_out(7, TRUE); } } return 0; }
int main(void) { if (PM->RCAUSE.reg & (PM_RCAUSE_POR | PM_RCAUSE_BOD12 | PM_RCAUSE_BOD33)) { // On powerup, force a clean reset of the MT7620 pin_low(PIN_SOC_RST); pin_out(PIN_SOC_RST); // turn off 3.3V to SoC pin_low(PIN_SOC_PWR); pin_out(PIN_SOC_PWR); // pull 1.8V low pin_low(PIN_18_V); pin_out(PIN_18_V); clock_init_crystal(GCLK_SYSTEM, GCLK_32K); timer_clock_enable(TC_BOOT); // hold everything low boot_delay_ms(50); // power off for 50ms pin_high(PIN_SOC_PWR); boot_delay_ms(2); // 2ms until 1.8 rail comes on pin_high(PIN_18_V); boot_delay_ms(50); // 50ms before soc rst comes on } else { clock_init_crystal(GCLK_SYSTEM, GCLK_32K); } pin_mux(PIN_USB_DM); pin_mux(PIN_USB_DP); usb_init(); usb_attach(); NVIC_SetPriority(USB_IRQn, 0xff); pin_high(PIN_LED); pin_out(PIN_LED); pin_in(PIN_SOC_RST); pin_high(PIN_SOC_PWR); pin_out(PIN_SOC_PWR); pin_low(PORT_A.power); pin_out(PORT_A.power); pin_low(PORT_B.power); pin_out(PORT_B.power); pin_pull_up(PIN_BRIDGE_CS); pin_pull_up(PIN_FLASH_CS); pin_pull_up(PIN_SERIAL_TX); pin_pull_up(PIN_SERIAL_RX); dma_init(); NVIC_EnableIRQ(DMAC_IRQn); NVIC_SetPriority(DMAC_IRQn, 0xff); eic_init(); NVIC_EnableIRQ(EIC_IRQn); NVIC_SetPriority(EIC_IRQn, 0xff); evsys_init(); NVIC_EnableIRQ(EVSYS_IRQn); NVIC_SetPriority(EVSYS_IRQn, 0); adc_init(GCLK_SYSTEM, ADC_REFCTRL_REFSEL_INTVCC1); dac_init(GCLK_32K); bridge_init(); port_init(&port_a, 1, &PORT_A, GCLK_PORT_A, TCC_PORT_A, DMA_PORT_A_TX, DMA_PORT_A_RX); port_init(&port_b, 2, &PORT_B, GCLK_PORT_B, TCC_PORT_B, DMA_PORT_B_TX, DMA_PORT_B_RX); __enable_irq(); SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk; init_systick(); while (1) { __WFI(); } }