Schaltplan des angeschlossenen LED Balkens
Die Bibliothek muß intern mit den folgenden Parametern übersetzt werden. Dies kann durch Benutzung der originalen Boardkonfiguration über --enable-board=avrctrl-8535-8mhz
erreicht werden:
AVRHAL_LIB_LED_PORT="PORTB
"AVRHAL_LIB_LED_PORT_DDR="DDRB
"AVRHAL_LIB_LED_PORT_IN="PINB
"AVRHAL_LIB_LED_OFF="0
"
#include <avrhal/delay.h>
#include <avrhal/led.h>
#define MAX_LEVEL 32 enum { UP, DOWN } direction;
int main(void) { int8_t led = 0; led_init(); led_graph_control(2*MAX_LEVEL, LED_BAR | LED_MARGIN(/* Bit */ 4 /* is margin */));
while (1) { led_graph_put((int16_t)led); delay_ms(10); /* direction state machine */ switch (direction) { case UP: /* count up means * shift left */ led++; if (led == MAX_LEVEL) { /* change direction */ direction = DOWN; } break; case DOWN: /* count down means * shift right */ led--; if (led == -MAX_LEVEL) { /* change direction */ direction = UP; } break; default: break; } } } /* main() */
doc/examples/ledband
entnommen werden.[avr@host] > avr-gcc -g -O2 -Wall -Wstrict-prototypes -Wa \ -mmcu=at90s8535 -DAVRHAL_CONFIG_avrctrl_8535_8mhz \ -c -o main.o main.c
[avr@host] > avr-gcc -Wl,-Map=ledband.map,--cref -mmcu=at90s8535 \ -o ledband.out main.o -lavrhal-avrctrl-8535-8mhz
[avr@host] > avr-objcopy -O binary -R .eeprom ledband.out ledband.out-rom.bin [avr@host] > avr-objcopy -O ihex -R .eeprom ledband.out ledband.out-rom.hex [avr@host] > avr-objcopy -O srec -R .eeprom ledband.out ledband.out-rom.s19
S01200006C656462616E642D726F6D2E7331399D S113000010C02AC029C028C027C026C025C024C0CB S113001023C022C021C020C01FC01EC01DC01CC0E0 S11300201BC011241FBECFE5D2E0DEBFCDBF10E060 S1130030A0E6B0E0E2E3F2E003C0C89531960D9289 S1130040A236B107D1F710E0A2E6B0E001C01D92DC S1130050A636B107E1F701C0D3CFCFE5D2E0DEBFCA S1130060CDBF10E08FEF87BB69E080E490E0C4D09F S1130070C0E0D0E08C2F9D2FB0D08AE090E023D058 S11300808091640090916500009789F0019791F741 S11300901150103E29F0C12FDD27C7FDD095EACFBE S11300A01092650010926400C0EEDFEFE3CF1F5F93 S11300B0103289F781E090E09093650080936400AA S11300C0C0E2D0E0D7CFE82FF92F309639F0A0ED79 S11300D0B7E01197F1F7A8953197C9F708958930DA S11300E0910584F0282F392F97FF02C0295F3F4FD5 S11300F043E0359527954A95E1F7309363002093C3 S1130100620008952FEF883F92077CF497FD0796CD S113011023E0959587952A95E1F7909581959F4FD2 S1130120909363008093620008951092630010928C S1130130620008950895982F80916000282F2695D5 S11301402770290F80FF3CC0622F772767FD7095C9 S1130150892F992787FD9095F72FE62FE81BF90B38 S1130160E617F707A4F421E030E0932F822F02C0B2 S1130170880F991F6A95E2F7482F480F4150932F33 S1130180822F02C0880F991FEA95E2F715C06E17F7 S11301907F07B4F421E030E0932F822F02C0880F50 S11301A0991FEA95E2F7482F4150932F822F02C0FE S11301B0880F991F6A95E2F78195482348BB0895F3 S11301C027FF02C018BA089581E090E002C0880FAA S11301D0991F2A95E2F788BB089560916200709197 S11301E063006115710529F00ED0972F862FA3DFC8 S11301F0089588BB089508951F93162F70DF1093F8 S113020060001F910895AA1BBB1B51E107C0AA1FE0 S1130210BB1FA617B70710F0A61BB70B881F991FA3 S11302205A95A9F780959095682F792F8A2F9B2F3F S105023008952B S10502320100C5 S9030000FC
[avr@host] > avr-objdump -x ledband.out > ledband.inf [avr@host] > avr-size -d ledband.out > ledband.siz [avr@host] > avr-size -x ledband.out >> ledband.siz
text data bss dec hex filename 562 2 4 568 238 ledband.out text data bss dec hex filename 0x232 0x2 0x4 568 238 ledband.out