int main() { //Initialize the pin_t structure with the pin port and number //On this board there is a LED on PG13 pin_t pin = make_pin(GPIO_PORT_G, 13); //configure the pin for output. gpio_config(pin, pin_dir_write, pull_down); //set the pin to HIGH gpio_set(pin, 1); return 0; }
int main() { pin = make_pin(GPIO_PORT_B, 4); gpio_config(pin, pin_dir_write, pull_down); int period = 32768; int prescale = 1; timer_init(3, 1, prescale, period); int i = 0; double decal = 1; while(1) { timer_init_pwmchannel(3, 1, pin, i); i = i + decal; decal = (i == period || i == 0) ? -1 * decal : decal; } return 0; }
ISR(TIMER5_COMPB_vect) { //tooth 59 interrupt tmr16_event_call(&chb5); tmr16_int_disable(&chb5); } ISR(TIMER5_COMPC_vect) { //mark interrupt tmr16_event_call(&chc5); tmr16_int_disable(&chc5); } ISR(TIMER5_OVF_vect) { //stop interrupt tmr16_event_call(&ovf5); tmr16_int_disable(&ovf5); } pin_t b4 = make_pin(B, 4); //coil14 out pin_t b5 = make_pin(B, 5); //coil23 out pin_t b6 = make_pin(B, 6); //emu out pin_t b7 = make_pin(B, 7); //test out pin_t l1 = make_pin(L, 1); //capture in void test_on(void) { // test/mark pin_on(&b7); } void test_off(void) { // test/mark pin_off(&b7); } void coil14_on(void) { pin_on(&b4);
/* * File: fan.c * Author: root * * Created on 27 Октябрь 2015 г., 20:50 */ #include <avr/io.h> #include <util/delay.h> #include "libs/ports.h" pin_t led = make_pin(B,7); int main() { pin_out(&led); while(1) { _delay_us(10); pin_toggle(&led); } }