<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=4&amp;t=24706&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2024-09-10T16:25:26+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=24706&amp;mode</id>
<entry>
<author><name><![CDATA[domson]]></name></author>
<updated>2024-09-10T16:25:26+01:00</updated>
<published>2024-09-10T16:25:26+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238494#p238494</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238494#p238494"/>
<title type="html"><![CDATA[Re: Problem z odbieraniem usbFunctionWrite]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238494#p238494"><![CDATA[
dobra jestem upośledzony:<br />[syntax=c]data_length = urq-&gt;wLength.word;// ilość znaków przesyłanego tekstu[/syntax]<br />tego mi zabrakło<br />nadal mam problemy ale teraz bardziej osobiste powiedzmy<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=22158">domson</a> — 10 wrz 2024, o 16:25</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2024-09-10T13:28:28+01:00</updated>
<published>2024-09-10T13:28:28+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238493#p238493</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238493#p238493"/>
<title type="html"><![CDATA[Re: Problem z odbieraniem usbFunctionWrite]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238493#p238493"><![CDATA[
<div class="quotetitle">domson napisał(a):</div><div class="quotecontent"><br />Nie wywaliłem go, a bazuję na Twoim projekcie?<br /></div><br />To jest całkiem zmieniony kod z książki, to jest twoja wersja main.c i nie powinno się tutaj zostawiać autora z książki - to jedno<br /><br />a drugie, zauważ, że prawie nikt nie odpisuje na twoje posty ale to nie dlatego że nie wiem - że ktoś cię nie lubi czy coś ....<br /><br />Ty po prostu drastycznie źle podchodzisz do przedstawiania i opisu problemu. Wrzucasz przysłowiowy hektolitr kodu i to specyficznego, związanego z jakimś twoim sprzętem i myślisz, że jeśli ktoś nie ma takiego sprzętu i nawet miałby miał ten sprzęt to ktoś ma czasu analizować taki kod i domyślać się co gdzie jest źle ?<br /><br />Zastanów się nad tym i zrozum, że jeśli oczekujesz szybkiej i porządnej pomocy to wydziel problem, opisz go dokładnie, pokaż ale FRAGMENT kodu który ew sprawia ci kłopot i dobrze opisz co chcesz uzyskać a co się dzieje<br /><br />mało kto zabierze się za analizę takiego kodu <br /><br />ja również wróżką niestety nie jestem i pomimo najszczerszych chęci nie mam czasu na analizy takich kodów. I nie piszę tego złośliwie tylko staram się podpowiedzieć ci, że pytań również warto uczyć się tzn jak je zadawać<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 10 wrz 2024, o 13:28</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[domson]]></name></author>
<updated>2024-09-10T08:51:57+01:00</updated>
<published>2024-09-10T08:51:57+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238492#p238492</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238492#p238492"/>
<title type="html"><![CDATA[Re: Problem z odbieraniem usbFunctionWrite]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238492#p238492"><![CDATA[
Nie wywaliłem go, a bazuję na Twoim projekcie?<br />Ale poza tym innych problemów nie widzisz?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=22158">domson</a> — 10 wrz 2024, o 08:51</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2024-09-10T08:12:08+01:00</updated>
<published>2024-09-10T08:12:08+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238491#p238491</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238491#p238491"/>
<title type="html"><![CDATA[Re: Problem z odbieraniem usbFunctionWrite]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238491#p238491"><![CDATA[
co to za praktyki żeby w nagłówku dawać moje imię i nazwisko ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 10 wrz 2024, o 08:12</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[domson]]></name></author>
<updated>2024-09-09T20:46:05+01:00</updated>
<published>2024-09-09T20:46:05+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238490#p238490</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238490#p238490"/>
<title type="html"><![CDATA[Re: Problem z odbieraniem usbFunctionWrite]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238490#p238490"><![CDATA[
zmodyfikowałem już bez przerwania nadal dziwnie[syntax=c]/*<br /> * main.c<br /> *<br /> *  Created on: 16 lut 2018<br /> *      Author: Mirosław Kardaś<br /> *      web: www.atnel.pl<br /> */<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &lt;avr/wdt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;stdlib.h&gt;<br />// skompilowano dla F_CPU = 16 MHz<br /><br />#include &quot;usbdrv/usbdrv.h&quot;<br /><br />// usb user requests<br />enum {<br />cmd_cls,<br />cmd_cls1,<br />cmd_cls2,<br />cmd_locate,<br />cmd_text,<br />cmd_bck_on,<br />};<br /><br />uint8_t data_length;<br /><br />//---- led macros -----------<br /><br /><br /><br />enum{<br />poczatek,<br />set_e1,<br />set_e2,<br />set_v0,<br />_lcd_clear,<br />_display_on_off_control,<br />_set_cursor,<br />set_cgram_address,<br />set_bk,<br />przeplatane_adres_dane,<br />przeplatane_dane_adres,<br />modified_chars_wr,<br />send_byte,<br />};<br /><br /><br />#define address_slavea 0x11 &lt;&lt; 1<br />#define busy_flag 7<br /><br />#define LCD_CLEAR 1<br />#define LCD_HOME 1&lt;&lt;1<br />#define LCDC_ENTRY_MODE0x04<br />#define LCD_EM_SHIFT_CURSOR    0x00<br />#define LCD_EM_SHIFT_DISPLAY 0x01<br />#define LCD_EM_LEFT   0x00<br />#define LCD_EM_RIGHT0x02<br />#define LCD_ONOFF0x08<br />#define LCD_DISP_ON    0x04<br />#define LCD_CURSOR_ON0x02<br />#define LCDC_CURSOR_OFF0x00<br />#define LCDC_BLINK_ON0x01<br />#define LCDC_BLINK_OFF0x00<br />#define LCD_SHIFT0x10<br />#define LCDC_SHIFT_DISP0x08<br />#define LCDC_SHIFT_CURSOR0x00<br />#define LCDC_SHIFT_RIGHT0x04<br />#define LCDC_SHIFT_LEFT0x00<br />#define LCD_FUNC0x20<br />#define LCD_8_BIT0x10<br />#define LCD_4_BIT0x00<br />#define LCDC_TWO_LINE0x08<br />#define LCDC_FONT_5x100x04<br />#define LCDC_FONT_5x70x00<br />#define LCDC_SET_CGRAM0x40<br />#define LCDC_SET_DDRAM0x80<br />#define initial_i2c (1 &lt;&lt; TWINT) | (0 &lt;&lt; TWEA) | (0 &lt;&lt; TWWC) | (1 &lt;&lt; TWEN) | (0 &lt;&lt; TWIE)<br />#define end_of_first_line 0x10<br />#define end_of_second_line 0x50<br /><br />volatile unsigned char buf&#91;256&#93;;<br />volatile unsigned char obszar&#91;16&#93;;<br />volatile unsigned char il_kom;<br />volatile unsigned char dol_buf;<br />volatile unsigned char dol_ob;<br />volatile uint8_t zajete;<br />volatile uint16_t Timer1, Timer2, Timer3;<br /><br /><br />inline void red_on(void){<br />PORTD |= 1 &lt;&lt; 7;<br />}<br /><br />void wr_data_i2c (uint8_t a){<br />unsigned char b;<br />unsigned char d;<br />for (d = obszar&#91;dol_ob&#93;, b = 0; ((b &lt; 15) &amp;&amp; obszar&#91;dol_ob + b + 1&#93;);d += obszar&#91;dol_ob + (++b)&#93;);<br />obszar&#91;dol_ob + b&#93;++;<br />buf&#91;dol_buf + d&#93; = a;<br />}<br />void wr_cmd_i2c (uint8_t a){<br />unsigned char b;<br />unsigned char d;<br />for (b = 0, d = 0; ((b &lt; 16) &amp;&amp; obszar&#91;dol_ob + b&#93;); b++){<br />d += obszar&#91;dol_ob + b&#93;;<br />}<br />if(b &lt; 16){<br />obszar&#91;dol_ob + b&#93; = 1;<br />buf&#91;dol_buf + d&#93; = a;<br />}<br />else{<br />red_on();<br />}<br />}<br />void send_buf (void){<br />if(!zajete){<br />zajete = 1;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTA);<br />}<br />}<br /><br /><br />char ibf&#91;&#93; = &quot;123ab678&quot;;<br />// nagłówek funkcji do wymuszenia renumeracji na usb<br /><br />void usb_reset( void );<br /><br />usbMsgLen_t usbFunctionSetup( uchar data&#91;8&#93; ) {<br /><br />uint8_t lokalizacja;<br />usbMsgLen_t len = 0;<br />usbRequest_t * urq = (usbRequest_t*)data;<br /><br />switch( urq-&gt;bRequest ) {<br />case cmd_cls:<br />wr_cmd_i2c(_lcd_clear);<br />send_buf();<br />break;<br />case cmd_cls1:<br />lokalizacja = 0x00;<br />//no break<br /><br />case cmd_cls2:<br />lokalizacja = 0x14;<br />wr_cmd_i2c(_set_cursor);<br />wr_data_i2c(lokalizacja);<br />for( uint8_t i=0; i &lt; 40; i++ ){<br />wr_data_i2c(' ');<br />}<br />send_buf();<br />break;<br /><br />case cmd_locate:<br />if((urq-&gt;wValue.bytes&#91;0&#93;) &lt; 4){<br />wr_cmd_i2c(_set_cursor);<br />wr_data_i2c((urq-&gt;wValue.bytes&#91;1&#93;) + (40 * (urq-&gt;wValue.bytes&#91;0&#93;)));<br />}<br />else{<br />data_length = urq-&gt;wLength.word;// ilość znaków przesyłanego tekstu<br />wr_cmd_i2c(set_v0);<br />wr_data_i2c(urq-&gt;wValue.bytes&#91;1&#93;);<br />}<br />send_buf();<br />break;<br /><br />case cmd_text:<br />wr_cmd_i2c(send_byte);<br />return USB_NO_MSG;// ... ciąg dalszy w funkcji usbFunctionWrite()<br />break;<br /><br />case cmd_bck_on:<br />wr_cmd_i2c(set_bk);<br />if( urq-&gt;wValue.word ) {<br />wr_data_i2c(128);<br />}<br />else {<br />wr_data_i2c(0);<br />}<br />send_buf();<br />break;<br />}<br /><br />    return  len;<br />}<br /><br /><br />uchar usbFunctionWrite( uchar * data, uchar len ) {<br /><br />for(uint8_t a = 0; a &lt; len; a++){<br />wr_data_i2c(data&#91;a&#93;);<br />}<br /><br />data_length -= len;<br /><br />if( data_length &lt;= 0 ) {<br />send_buf();<br />return 1;// koniec<br /><br />}<br />else return 0;// oczekiwanie na kolejne dane<br />}<br /><br />int main( void ) {<br />DDRD = (1 &lt;&lt; 5) | (1 &lt;&lt; 7);<br />DDRA = 0xff;<br />PORTB = 0xff;<br />PORTD = (1 &lt;&lt; 0) | (1 &lt;&lt; 1) | (1 &lt;&lt; 6);<br /><br />//i2c<br />TWBR = 30;<br />//i2c<br /><br />wdt_enable(WDTO_1S);// aktywacja watchdoga na 1 s<br /><br />// inicjalizacja sprzętowego Timera0<br />// do napędu timerów programowych<br />TCCR0A = (1&lt;&lt;WGM01);<br />TCCR0A |= (1&lt;&lt;CS02)|(1&lt;&lt;CS00);<br />TIMSK0 |= (1&lt;&lt;OCIE0A);<br />OCR0A = F_CPU/1024ul/100ul;<br /><br /><br />wdt_reset();// resetuj watchdog<br /><br />usbInit();// inicjalizacja V-USB<br />// wymuszenie enumeracji urządzenia<br />usb_reset();// reset urządzenia na magistrali USB<br /><br />sei();// globalne zezwolenie na przerwania<br /><br />while(1) {<br />usbPoll();// zdarzenie do obsługi USB<br />wdt_reset();// resetuj watchdog<br /><br />        if( !Timer2 ) {<br />        Timer2 = 100;<br />        if( usbInterruptIsReady() ) {<br />        usbSetInterrupt( (unsigned char*)ibf, 8 );<br />        }<br />        }<br />        if(TWCR &amp; (1 &lt;&lt; TWINT)){<br />PORTA = 1;<br />switch (TWSR){<br />case 0x08:<br />PORTA = 2;<br />//no break<br />case 0x10:<br />TWDR = address_slavea;<br />zajete++;<br />TWCR = initial_i2c;<br />PORTA = 3;<br />break;<br /><br />case 0x28:<br />dol_buf = dol_buf + 1;<br />obszar&#91;dol_ob&#93;--;<br />PORTA = 4;<br />//no break<br />case 0x18:<br />zajete = 1;<br />PORTA = 5;<br />if(obszar&#91;dol_ob&#93;){<br />PORTA = 6;<br />TWDR = buf&#91;dol_buf&#93;;<br />TWCR = initial_i2c;<br />}<br />else{<br />PORTA = 7;<br />il_kom--;<br />dol_ob = (dol_ob + 1) &amp; 0x0f;<br />if(il_kom){<br />PORTA = 8;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTA);<br />}<br />else{<br />PORTA = 9;<br />zajete = 0;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTO);<br />}<br />}<br />break;<br /><br />case 0x20:<br />PORTA = 10;<br />if(zajete &lt;= 8){<br />TWDR = address_slavea;<br />TWCR = initial_i2c;<br />}<br />else{<br />red_on();<br />zajete = 0;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTO);<br />}<br />break;<br /><br />case 0x30:<br />PORTA = 11;<br />if(zajete &lt; 30){<br />PORTA = 12;<br />TWDR = buf&#91;dol_buf&#93;;<br />zajete++;<br />TWCR = initial_i2c;<br />}<br />else{<br />PORTA = 13;<br />red_on();<br />zajete = 0;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTO);<br />}<br />break;<br /><br />default:<br />PORTA = 14;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTA);<br />break;<br />}        }<br />}<br />}<br /><br />void usb_reset( void ) {<br />usbDeviceDisconnect();<br />uint8_t i = 0;<br />while(--i){         // odłączenie się do magistrali USB<br />    wdt_reset();    // na czas większy niż ok 250 ms<br />    _delay_ms(1);   //<br />}<br />usbDeviceConnect();<br />}<br /><br /><br />// napęd timerów programowych<br />ISR( TIMER0_COMPA_vect, ISR_NOBLOCK ) {<br /><br />uint16_t n;<br /><br />n = Timer1;<br />if( n ) Timer1 = --n;<br /><br /><br />n = Timer2;<br />if( n ) Timer2 = --n;<br /><br />n = Timer3;<br />if( n ) Timer3 = --n;<br />}<br /><br /><br />#ifdef WDIF<br />    void __init3( void )  __attribute__ (( section( &quot;.init3&quot; ), naked, used ));<br />    void __init3( void )<br />    {<br />        /* wyłączenie watchdoga (w tych mikrokontrolerach, w których watchdog<br />         * ma możliwość generowania przerwania pozostaje on też aktywny po<br />         * resecie) */<br />        MCUSR = 0;<br />        _WD_CONTROL_REG = 1 &lt;&lt; _WD_CHANGE_BIT | 1 &lt;&lt; WDE;<br />        _WD_CONTROL_REG = 0;<br />    }<br />#endif[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=22158">domson</a> — 9 wrz 2024, o 20:46</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[domson]]></name></author>
<updated>2024-09-08T19:41:58+01:00</updated>
<published>2024-09-08T19:41:58+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238489#p238489</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238489#p238489"/>
<title type="html"><![CDATA[Re: Problem z odbieraniem usbFunctionWrite]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238489#p238489"><![CDATA[
Problemy z dziwnymi znakami się zazwyczaj dopiero po jakimś czasie objawiają.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=22158">domson</a> — 8 wrz 2024, o 19:41</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[domson]]></name></author>
<updated>2024-09-08T18:14:32+01:00</updated>
<published>2024-09-08T18:14:32+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238488#p238488</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238488#p238488"/>
<title type="html"><![CDATA[Problem z odbieraniem usbFunctionWrite]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24706&amp;p=238488#p238488"><![CDATA[
dobry<br />Mógłby mi ktoś pomóc i powiedzieć, dlaczego kod:<br />[syntax=c]/*<br /> * main.c<br /> *<br /> *  Created on: 16 lut 2018<br /> *      Author: Mirosław Kardaś<br /> *      web: www.atnel.pl<br /> */<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &lt;avr/wdt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;stdlib.h&gt;<br />// skompilowano dla F_CPU = 16 MHz<br /><br />#include &quot;usbdrv/usbdrv.h&quot;<br /><br />// usb user requests<br />enum {<br />cmd_cls,<br />cmd_cls1,<br />cmd_cls2,<br />cmd_locate,<br />cmd_text,<br />cmd_bck_on,<br />};<br /><br />uint8_t data_length;<br /><br />//---- led macros -----------<br /><br /><br /><br />enum{<br />poczatek,<br />set_e1,<br />set_e2,<br />set_v0,<br />_lcd_clear,<br />_display_on_off_control,<br />_set_cursor,<br />set_cgram_address,<br />set_bk,<br />przeplatane_adres_dane,<br />przeplatane_dane_adres,<br />modified_chars_wr,<br />send_byte,<br />};<br /><br /><br />#define address_slavea 0x11 &lt;&lt; 1<br />#define busy_flag 7<br /><br />#define LCD_CLEAR 1<br />#define LCD_HOME 1&lt;&lt;1<br />#define LCDC_ENTRY_MODE0x04<br />#define LCD_EM_SHIFT_CURSOR    0x00<br />#define LCD_EM_SHIFT_DISPLAY 0x01<br />#define LCD_EM_LEFT   0x00<br />#define LCD_EM_RIGHT0x02<br />#define LCD_ONOFF0x08<br />#define LCD_DISP_ON    0x04<br />#define LCD_CURSOR_ON0x02<br />#define LCDC_CURSOR_OFF0x00<br />#define LCDC_BLINK_ON0x01<br />#define LCDC_BLINK_OFF0x00<br />#define LCD_SHIFT0x10<br />#define LCDC_SHIFT_DISP0x08<br />#define LCDC_SHIFT_CURSOR0x00<br />#define LCDC_SHIFT_RIGHT0x04<br />#define LCDC_SHIFT_LEFT0x00<br />#define LCD_FUNC0x20<br />#define LCD_8_BIT0x10<br />#define LCD_4_BIT0x00<br />#define LCDC_TWO_LINE0x08<br />#define LCDC_FONT_5x100x04<br />#define LCDC_FONT_5x70x00<br />#define LCDC_SET_CGRAM0x40<br />#define LCDC_SET_DDRAM0x80<br />#define initial_i2c (0 &lt;&lt; TWINT) | (0 &lt;&lt; TWEA) | (0 &lt;&lt; TWWC) | (1 &lt;&lt; TWEN) | (1 &lt;&lt; TWIE)<br />#define end_of_first_line 0x10<br />#define end_of_second_line 0x50<br /><br />volatile unsigned char buf&#91;256&#93;;<br />volatile unsigned char obszar&#91;16&#93;;<br />volatile unsigned char il_kom;<br />volatile unsigned char dol_buf;<br />volatile unsigned char dol_ob;<br />volatile uint8_t zajete;<br />volatile uint16_t Timer1, Timer2, Timer3;<br /><br /><br />inline void red_on(void){<br />PORTD |= 1 &lt;&lt; 7;<br />}<br /><br />void wr_data_i2c (uint8_t a){<br />unsigned char b;<br />unsigned char d;<br />for (d = obszar&#91;dol_ob&#93;, b = 0; ((b &lt; 15) &amp;&amp; obszar&#91;dol_ob + b + 1&#93;);d += obszar&#91;dol_ob + (++b)&#93;);<br />obszar&#91;dol_ob + b&#93;++;<br />buf&#91;dol_buf + d&#93; = a;<br />}<br />void wr_cmd_i2c (uint8_t a){<br />unsigned char b;<br />unsigned char d;<br />for (b = 0, d = 0; ((b &lt; 16) &amp;&amp; obszar&#91;dol_ob + b&#93;); b++){<br />d += obszar&#91;dol_ob + b&#93;;<br />}<br />if(b &lt; 16){<br />obszar&#91;dol_ob + b&#93; = 1;<br />buf&#91;dol_buf + d&#93; = a;<br />}<br />else{<br />red_on();<br />}<br />}<br />void send_buf (void){<br />if(!zajete){<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTA) | (1 &lt;&lt; TWINT);<br />zajete = 1;<br />}<br />}<br /><br /><br />char ibf&#91;&#93; = &quot;123ab678&quot;;<br />// nagłówek funkcji do wymuszenia renumeracji na usb<br /><br />void usb_reset( void );<br /><br />usbMsgLen_t usbFunctionSetup( uchar data&#91;8&#93; ) {<br /><br />uint8_t lokalizacja;<br />usbMsgLen_t len = 0;<br />usbRequest_t * urq = (usbRequest_t*)data;<br /><br />switch( urq-&gt;bRequest ) {<br />case cmd_cls:<br />wr_cmd_i2c(_lcd_clear);<br />send_buf();<br />break;<br />case cmd_cls1:<br />lokalizacja = 0x00;<br />//no break<br /><br />case cmd_cls2:<br />lokalizacja = 0x14;<br />wr_cmd_i2c(_set_cursor);<br />wr_data_i2c(lokalizacja);<br />for( uint8_t i=0; i &lt; 40; i++ ){<br />wr_data_i2c(' ');<br />}<br />send_buf();<br />break;<br /><br />case cmd_locate:<br />if((urq-&gt;wValue.bytes&#91;0&#93;) &lt; 4){<br />wr_cmd_i2c(_set_cursor);<br />wr_data_i2c((urq-&gt;wValue.bytes&#91;1&#93;) + (40 * (urq-&gt;wValue.bytes&#91;0&#93;)));<br />}<br />else{<br />data_length = urq-&gt;wLength.word;// ilość znaków przesyłanego tekstu<br />wr_cmd_i2c(set_v0);<br />wr_data_i2c(urq-&gt;wValue.bytes&#91;1&#93;);<br />}<br />send_buf();<br />break;<br /><br />case cmd_text:<br />wr_cmd_i2c(send_byte);<br />return USB_NO_MSG;// ... ciąg dalszy w funkcji usbFunctionWrite()<br />break;<br /><br />case cmd_bck_on:<br />wr_cmd_i2c(set_bk);<br />if( urq-&gt;wValue.word ) {<br />wr_data_i2c(128);<br />}<br />else {<br />wr_data_i2c(0);<br />}<br />send_buf();<br />break;<br />}<br /><br />    return  len;<br />}<br /><br /><br />uchar usbFunctionWrite( uchar * data, uchar len ) {<br /><br />for(uint8_t a = 0; a &lt; len; a++){<br />wr_data_i2c(data&#91;a&#93;);<br />}<br /><br />data_length -= len;<br /><br />if( data_length &lt;= 0 ) {<br />send_buf();<br />return 1;// koniec<br /><br />}<br />else return 0;// oczekiwanie na kolejne dane<br />}<br /><br />int main( void ) {<br />DDRD = (1 &lt;&lt; 5) | (1 &lt;&lt; 7);<br />DDRA = 0xff;<br />PORTB = 0xff;<br />PORTD = (1 &lt;&lt; 0) | (1 &lt;&lt; 1) | (1 &lt;&lt; 6);<br /><br />//i2c<br />TWBR = 30;<br />//i2c<br /><br />wdt_enable(WDTO_1S);// aktywacja watchdoga na 1 s<br /><br />// inicjalizacja sprzętowego Timera0<br />// do napędu timerów programowych<br />TCCR0A = (1&lt;&lt;WGM01);<br />TCCR0A |= (1&lt;&lt;CS02)|(1&lt;&lt;CS00);<br />TIMSK0 |= (1&lt;&lt;OCIE0A);<br />OCR0A = F_CPU/1024ul/100ul;<br /><br /><br />wdt_reset();// resetuj watchdog<br /><br />usbInit();// inicjalizacja V-USB<br />// wymuszenie enumeracji urządzenia<br />usb_reset();// reset urządzenia na magistrali USB<br /><br />sei();// globalne zezwolenie na przerwania<br /><br />while(1) {<br />usbPoll();// zdarzenie do obsługi USB<br />wdt_reset();// resetuj watchdog<br /><br />        if( !Timer2 ) {<br />        Timer2 = 100;<br />        if( usbInterruptIsReady() ) {<br />        usbSetInterrupt( (unsigned char*)ibf, 8 );<br />        }<br />        }<br /><br />}<br />}<br /><br />void usb_reset( void ) {<br />usbDeviceDisconnect();<br />uint8_t i = 0;<br />while(--i){         // odłączenie się do magistrali USB<br />    wdt_reset();    // na czas większy niż ok 250 ms<br />    _delay_ms(1);   //<br />}<br />usbDeviceConnect();<br />}<br /><br />ISR(TWI_vect){<br />PORTA = 1;<br />switch (TWSR){<br />case 0x08:<br />PORTA = 2;<br />//no break<br />case 0x10:<br />TWDR = address_slavea;<br />zajete++;<br />TWCR = initial_i2c | (1 &lt;&lt; TWINT);<br />PORTA = 3;<br />break;<br /><br />case 0x28:<br />dol_buf = dol_buf + 1;<br />obszar&#91;dol_ob&#93;--;<br />PORTA = 4;<br />//no break<br />case 0x18:<br />zajete = 1;<br />PORTA = 5;<br />if(obszar&#91;dol_ob&#93;){<br />PORTA = 6;<br />TWDR = buf&#91;dol_buf&#93;;<br />TWCR = initial_i2c | (1 &lt;&lt; TWINT);<br />}<br />else{<br />PORTA = 7;<br />il_kom--;<br />dol_ob = (dol_ob + 1) &amp; 0x0f;<br />if(il_kom){<br />PORTA = 8;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTA) | (1 &lt;&lt; TWINT);<br />}<br />else{<br />PORTA = 9;<br />zajete = 0;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTO) | (1 &lt;&lt; TWINT);<br />}<br />}<br />break;<br /><br />case 0x20:<br />PORTA = 10;<br />if(zajete &lt;= 8){<br />TWDR = address_slavea;<br />TWCR = initial_i2c | (1 &lt;&lt; TWINT);<br />}<br />else{<br />red_on();<br />zajete = 0;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTO)  | (1 &lt;&lt; TWINT);<br />}<br />break;<br /><br />case 0x30:<br />PORTA = 11;<br />if(zajete &lt; 30){<br />PORTA = 12;<br />TWDR = buf&#91;dol_buf&#93;;<br />zajete++;<br />TWCR = initial_i2c | (1 &lt;&lt; TWINT);<br />}<br />else{<br />PORTA = 13;<br />red_on();<br />zajete = 0;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTO) | (1 &lt;&lt; TWINT);<br />}<br />break;<br /><br />default:<br />PORTA = 14;<br />TWCR = initial_i2c | (1 &lt;&lt; TWSTA) | (1 &lt;&lt; TWINT);<br />break;<br />}<br />}<br />// napęd timerów programowych<br />ISR( TIMER0_COMPA_vect, ISR_NOBLOCK ) {<br /><br />uint16_t n;<br /><br />n = Timer1;<br />if( n ) Timer1 = --n;<br /><br /><br />n = Timer2;<br />if( n ) Timer2 = --n;<br /><br />n = Timer3;<br />if( n ) Timer3 = --n;<br />}<br /><br /><br />#ifdef WDIF<br />    void __init3( void )  __attribute__ (( section( &quot;.init3&quot; ), naked, used ));<br />    void __init3( void )<br />    {<br />        /* wyłączenie watchdoga (w tych mikrokontrolerach, w których watchdog<br />         * ma możliwość generowania przerwania pozostaje on też aktywny po<br />         * resecie) */<br />        MCUSR = 0;<br />        _WD_CONTROL_REG = 1 &lt;&lt; _WD_CHANGE_BIT | 1 &lt;&lt; WDE;<br />        _WD_CONTROL_REG = 0;<br />    }<br />#endif[/syntax]<br />[syntax=c]/* Name: usbconfig.h<br /> * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers<br /> * Author: Christian Starkjohann<br /> * Creation Date: 2005-04-01<br /> * Tabsize: 4<br /> * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH<br /> * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)<br /> */<br /><br />#ifndef __usbconfig_h_included__<br />#define __usbconfig_h_included__<br />#include &lt;avr/io.h&gt;<br /><br />/*<br />General Description:<br />This file is an example configuration (with inline documentation) for the USB<br />driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is<br />also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may<br />wire the lines to any other port, as long as D+ is also wired to INT0 (or any<br />other hardware interrupt, as long as it is the highest level interrupt, see<br />section at the end of this file).<br />+ To create your own usbconfig.h file, copy this file to your project's<br />+ firmware source directory) and rename it to &quot;usbconfig.h&quot;.<br />+ Then edit it accordingly.<br />*/<br /><br />/* ---------------------------- Hardware Config ---------------------------- */<br /><br />#define USB_CFG_IOPORTNAME      D<br />/* This is the port where the USB bus is connected. When you configure it to<br /> * &quot;B&quot;, the registers PORTB, PINB and DDRB will be used.<br /> */<br />#define USB_CFG_DMINUS_BIT      3<br />/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.<br /> * This may be any bit in the port.<br /> */<br />#define USB_CFG_DPLUS_BIT       2<br />/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.<br /> * This may be any bit in the port. Please note that D+ must also be connected<br /> * to interrupt pin INT0! &#91;You can also use other interrupts, see section<br /> * &quot;Optional MCU Description&quot; below, or you can connect D- to the interrupt, as<br /> * it is required if you use the USB_COUNT_SOF feature. If you use D- for the<br /> * interrupt, the USB interrupt will also be triggered at Start-Of-Frame<br /> * markers every millisecond.&#93;<br /> */<br />#define USB_CFG_CLOCK_KHZ       16000<br />/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,<br /> * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code<br /> * require no crystal, they tolerate +/- 1% deviation from the nominal<br /> * frequency. All other rates require a precision of 2000 ppm and thus a<br /> * crystal!<br /> * Since F_CPU should be defined to your actual clock rate anyway, you should<br /> * not need to modify this setting.<br /> */<br />#define USB_CFG_CHECK_CRC       0<br />/* Define this to 1 if you want that the driver checks integrity of incoming<br /> * data packets (CRC checks). CRC checks cost quite a bit of code size and are<br /> * currently only available for 18 MHz crystal clock. You must choose<br /> * USB_CFG_CLOCK_KHZ = 18000 if you enable this option.<br /> */<br /><br />/* ----------------------- Optional Hardware Config ------------------------ */<br /><br />#define USB_CFG_PULLUP_IOPORTNAME   D<br />/* If you connect the 1.5k pullup resistor from D- to a port pin instead of<br /> * V+, you can connect and disconnect the device from firmware by calling<br /> * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).<br /> * This constant defines the port on which the pullup resistor is connected.<br /> */<br />#define USB_CFG_PULLUP_BIT          4<br />/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined<br /> * above) where the 1.5k pullup resistor is connected. See description<br /> * above for details.<br /> */<br /><br />/* --------------------------- Functional Range ---------------------------- */<br /><br />#define USB_CFG_HAVE_INTRIN_ENDPOINT    1<br />/* Define this to 1 if you want to compile a version with two endpoints: The<br /> * default control endpoint 0 and an interrupt-in endpoint (any other endpoint<br /> * number).<br /> */<br />#define USB_CFG_HAVE_INTRIN_ENDPOINT3   0<br />/* Define this to 1 if you want to compile a version with three endpoints: The<br /> * default control endpoint 0, an interrupt-in endpoint 3 (or the number<br /> * configured below) and a catch-all default interrupt-in endpoint as above.<br /> * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.<br /> */<br />#define USB_CFG_EP3_NUMBER              3<br />/* If the so-called endpoint 3 is used, it can now be configured to any other<br /> * endpoint number (except 0) with this macro. Default if undefined is 3.<br /> */<br />/* #define USB_INITIAL_DATATOKEN           USBPID_DATA1 */<br />/* The above macro defines the startup condition for data toggling on the<br /> * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.<br /> * Since the token is toggled BEFORE sending any data, the first packet is<br /> * sent with the oposite value of this configuration!<br /> */<br />#define USB_CFG_IMPLEMENT_HALT          0<br />/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature<br /> * for endpoint 1 (interrupt endpoint). Although you may not need this feature,<br /> * it is required by the standard. We have made it a config option because it<br /> * bloats the code considerably.<br /> */<br />#define USB_CFG_SUPPRESS_INTR_CODE      0<br />/* Define this to 1 if you want to declare interrupt-in endpoints, but don't<br /> * want to send any data over them. If this macro is defined to 1, functions<br /> * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if<br /> * you need the interrupt-in endpoints in order to comply to an interface<br /> * (e.g. HID), but never want to send any data. This option saves a couple<br /> * of bytes in flash memory and the transmit buffers in RAM.<br /> */<br />#define USB_CFG_INTR_POLL_INTERVAL      10<br />/* If you compile a version with endpoint 1 (interrupt-in), this is the poll<br /> * interval. The value is in milliseconds and must not be less than 10 ms for<br /> * low speed devices.<br /> */<br />#define USB_CFG_IS_SELF_POWERED         0<br />/* Define this to 1 if the device has its own power supply. Set it to 0 if the<br /> * device is powered from the USB bus.<br /> */<br />#define USB_CFG_MAX_BUS_POWER           100<br />/* Set this variable to the maximum USB bus power consumption of your device.<br /> * The value is in milliamperes. &#91;It will be divided by two since USB<br /> * communicates power requirements in units of 2 mA.&#93;<br /> */<br />#define USB_CFG_IMPLEMENT_FN_WRITE      1<br />/* Set this to 1 if you want usbFunctionWrite() to be called for control-out<br /> * transfers. Set it to 0 if you don't need it and want to save a couple of<br /> * bytes.<br /> */<br />#define USB_CFG_IMPLEMENT_FN_READ       0<br />/* Set this to 1 if you need to send control replies which are generated<br /> * &quot;on the fly&quot; when usbFunctionRead() is called. If you only want to send<br /> * data from a static buffer, set it to 0 and return the data from<br /> * usbFunctionSetup(). This saves a couple of bytes.<br /> */<br />#define USB_CFG_IMPLEMENT_FN_WRITEOUT   0<br />/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.<br /> * You must implement the function usbFunctionWriteOut() which receives all<br /> * interrupt/bulk data sent to any endpoint other than 0. The endpoint number<br /> * can be found in 'usbRxToken'.<br /> */<br />#define USB_CFG_HAVE_FLOWCONTROL        0<br />/* Define this to 1 if you want flowcontrol over USB data. See the definition<br /> * of the macros usbDisableAllRequests() and usbEnableAllRequests() in<br /> * usbdrv.h.<br /> */<br />#define USB_CFG_DRIVER_FLASH_PAGE       0<br />/* If the device has more than 64 kBytes of flash, define this to the 64 k page<br /> * where the driver's constants (descriptors) are located. Or in other words:<br /> * Define this to 1 for boot loaders on the ATMega128.<br /> */<br />#define USB_CFG_LONG_TRANSFERS          0<br />/* Define this to 1 if you want to send/receive blocks of more than 254 bytes<br /> * in a single control-in or control-out transfer. Note that the capability<br /> * for long transfers increases the driver size.<br /> */<br />/* #define USB_RX_USER_HOOK(data, len)     if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */<br />/* This macro is a hook if you want to do unconventional things. If it is<br /> * defined, it's inserted at the beginning of received message processing.<br /> * If you eat the received message and don't want default processing to<br /> * proceed, do a return after doing your things. One possible application<br /> * (besides debugging) is to flash a status LED on each packet.<br /> */<br />/* #define USB_RESET_HOOK(resetStarts)     if(!resetStarts){hadUsbReset();} */<br />/* This macro is a hook if you need to know when an USB RESET occurs. It has<br /> * one parameter which distinguishes between the start of RESET state and its<br /> * end.<br /> */<br />/* #define USB_SET_ADDRESS_HOOK()              hadAddressAssigned(); */<br />/* This macro (if defined) is executed when a USB SET_ADDRESS request was<br /> * received.<br /> */<br />#define USB_COUNT_SOF                   0<br />/* define this macro to 1 if you need the global variable &quot;usbSofCount&quot; which<br /> * counts SOF packets. This feature requires that the hardware interrupt is<br /> * connected to D- instead of D+.<br /> */<br />/* #ifdef __ASSEMBLER__<br /> * macro myAssemblerMacro<br /> *     in      YL, TCNT0<br /> *     sts     timer0Snapshot, YL<br /> *     endm<br /> * #endif<br /> * #define USB_SOF_HOOK                    myAssemblerMacro<br /> * This macro (if defined) is executed in the assembler module when a<br /> * Start Of Frame condition is detected. It is recommended to define it to<br /> * the name of an assembler macro which is defined here as well so that more<br /> * than one assembler instruction can be used. The macro may use the register<br /> * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages<br /> * immediately after an SOF pulse may be lost and must be retried by the host.<br /> * What can you do with this hook? Since the SOF signal occurs exactly every<br /> * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in<br /> * designs running on the internal RC oscillator.<br /> * Please note that Start Of Frame detection works only if D- is wired to the<br /> * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!<br /> */<br />#define USB_CFG_CHECK_DATA_TOGGLING     0<br />/* define this macro to 1 if you want to filter out duplicate data packets<br /> * sent by the host. Duplicates occur only as a consequence of communication<br /> * errors, when the host does not receive an ACK. Please note that you need to<br /> * implement the filtering yourself in usbFunctionWriteOut() and<br /> * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable<br /> * for each control- and out-endpoint to check for duplicate packets.<br /> */<br />#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH   0<br />/* define this macro to 1 if you want the function usbMeasureFrameLength()<br /> * compiled in. This function can be used to calibrate the AVR's RC oscillator.<br /> */<br />#define USB_USE_FAST_CRC                0<br />/* The assembler module has two implementations for the CRC algorithm. One is<br /> * faster, the other is smaller. This CRC routine is only used for transmitted<br /> * messages where timing is not critical. The faster routine needs 31 cycles<br /> * per byte while the smaller one needs 61 to 69 cycles. The faster routine<br /> * may be worth the 32 bytes bigger code size if you transmit lots of data and<br /> * run the AVR close to its limit.<br /> */<br /><br />/* -------------------------- Device Description --------------------------- */<br /><br />#define  USB_CFG_VENDOR_ID       0xc0, 0x15 /* = 0x16c0 = 5824 = voti.nl */<br />/* USB vendor ID for the device, low byte first. If you have registered your<br /> * own Vendor ID, define it here. Otherwise you may use one of obdev's free<br /> * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!<br /> * *** IMPORTANT NOTE ***<br /> * This template uses obdev's shared VID/PID pair for Vendor Class devices<br /> * with libusb: 0x16c0/0x5dc.  Use this VID/PID pair ONLY if you understand<br /> * the implications!<br /> */<br />#define  USB_CFG_DEVICE_ID       0xdc, 0x06 /* = 0x05dc = 1500 */<br />/* This is the ID of the product, low byte first. It is interpreted in the<br /> * scope of the vendor ID. If you have registered your own VID with usb.org<br /> * or if you have licensed a PID from somebody else, define it here. Otherwise<br /> * you may use one of obdev's free shared VID/PID pairs. See the file<br /> * USB-IDs-for-free.txt for details!<br /> * *** IMPORTANT NOTE ***<br /> * This template uses obdev's shared VID/PID pair for Vendor Class devices<br /> * with libusb: 0x16c0/0x5dc.  Use this VID/PID pair ONLY if you understand<br /> * the implications!<br /> */<br />#define USB_CFG_DEVICE_VERSION  0x00, 0x01<br />/* Version number of the device: Minor number first, then major number.<br /> */<br />#define USB_CFG_VENDOR_NAME     'D', 'O', 'M', 'I', 'N', 'I', 'K'<br />#define USB_CFG_VENDOR_NAME_LEN 7<br />/* These two values define the vendor name returned by the USB device. The name<br /> * must be given as a list of characters under single quotes. The characters<br /> * are interpreted as Unicode (UTF-16) entities.<br /> * If you don't want a vendor name string, undefine these macros.<br /> * ALWAYS define a vendor name containing your Internet domain name if you use<br /> * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for<br /> * details.<br /> */<br />#define USB_CFG_DEVICE_NAME     'G', 'U', 'C', 'I', 'O'<br />#define USB_CFG_DEVICE_NAME_LEN 5<br />/* Same as above for the device name. If you don't want a device name, undefine<br /> * the macros. See the file USB-IDs-for-free.txt before you assign a name if<br /> * you use a shared VID/PID.<br /> */<br />/*#define USB_CFG_SERIAL_NUMBER   'N', 'o', 'n', 'e' */<br />/*#define USB_CFG_SERIAL_NUMBER_LEN   0 */<br />/* Same as above for the serial number. If you don't want a serial number,<br /> * undefine the macros.<br /> * It may be useful to provide the serial number through other means than at<br /> * compile time. See the section about descriptor properties below for how<br /> * to fine tune control over USB descriptors such as the string descriptor<br /> * for the serial number.<br /> */<br />#define USB_CFG_DEVICE_CLASS        0xff    /* set to 0 if deferred to interface */<br />#define USB_CFG_DEVICE_SUBCLASS     0<br />/* See USB specification if you want to conform to an existing device class.<br /> * Class 0xff is &quot;vendor specific&quot;.<br /> */<br />#define USB_CFG_INTERFACE_CLASS     0   /* define class here if not at device level */<br />#define USB_CFG_INTERFACE_SUBCLASS  0<br />#define USB_CFG_INTERFACE_PROTOCOL  0<br />/* See USB specification if you want to conform to an existing device class or<br /> * protocol. The following classes must be set at interface level:<br /> * HID class is 3, no subclass and protocol required (but may be useful!)<br /> * CDC class is 2, use subclass 2 and protocol 1 for ACM<br /> */<br />/* #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH    42 */<br />/* Define this to the length of the HID report descriptor, if you implement<br /> * an HID device. Otherwise don't define it or define it to 0.<br /> * If you use this define, you must add a PROGMEM character array named<br /> * &quot;usbHidReportDescriptor&quot; to your code which contains the report descriptor.<br /> * Don't forget to keep the array and this define in sync!<br /> */<br /><br />/* #define USB_PUBLIC static */<br />/* Use the define above if you #include usbdrv.c instead of linking against it.<br /> * This technique saves a couple of bytes in flash memory.<br /> */<br /><br />/* ------------------- Fine Control over USB Descriptors ------------------- */<br />/* If you don't want to use the driver's default USB descriptors, you can<br /> * provide our own. These can be provided as (1) fixed length static data in<br /> * flash memory, (2) fixed length static data in RAM or (3) dynamically at<br /> * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more<br /> * information about this function.<br /> * Descriptor handling is configured through the descriptor's properties. If<br /> * no properties are defined or if they are 0, the default descriptor is used.<br /> * Possible properties are:<br /> *   + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched<br /> *     at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is<br /> *     used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if<br /> *     you want RAM pointers.<br /> *   + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found<br /> *     in static memory is in RAM, not in flash memory.<br /> *   + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),<br /> *     the driver must know the descriptor's length. The descriptor itself is<br /> *     found at the address of a well known identifier (see below).<br /> * List of static descriptor names (must be declared PROGMEM if in flash):<br /> *   char usbDescriptorDevice&#91;&#93;;<br /> *   char usbDescriptorConfiguration&#91;&#93;;<br /> *   char usbDescriptorHidReport&#91;&#93;;<br /> *   char usbDescriptorString0&#91;&#93;;<br /> *   int usbDescriptorStringVendor&#91;&#93;;<br /> *   int usbDescriptorStringDevice&#91;&#93;;<br /> *   int usbDescriptorStringSerialNumber&#91;&#93;;<br /> * Other descriptors can't be provided statically, they must be provided<br /> * dynamically at runtime.<br /> *<br /> * Descriptor properties are or-ed or added together, e.g.:<br /> * #define USB_CFG_DESCR_PROPS_DEVICE   (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))<br /> *<br /> * The following descriptors are defined:<br /> *   USB_CFG_DESCR_PROPS_DEVICE<br /> *   USB_CFG_DESCR_PROPS_CONFIGURATION<br /> *   USB_CFG_DESCR_PROPS_STRINGS<br /> *   USB_CFG_DESCR_PROPS_STRING_0<br /> *   USB_CFG_DESCR_PROPS_STRING_VENDOR<br /> *   USB_CFG_DESCR_PROPS_STRING_PRODUCT<br /> *   USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER<br /> *   USB_CFG_DESCR_PROPS_HID<br /> *   USB_CFG_DESCR_PROPS_HID_REPORT<br /> *   USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)<br /> *<br /> * Note about string descriptors: String descriptors are not just strings, they<br /> * are Unicode strings prefixed with a 2 byte header. Example:<br /> * int  serialNumberDescriptor&#91;&#93; = {<br /> *     USB_STRING_DESCRIPTOR_HEADER(6),<br /> *     'S', 'e', 'r', 'i', 'a', 'l'<br /> * };<br /> */<br /><br />#define USB_CFG_DESCR_PROPS_DEVICE                  0<br />#define USB_CFG_DESCR_PROPS_CONFIGURATION           0<br />#define USB_CFG_DESCR_PROPS_STRINGS                 0<br />#define USB_CFG_DESCR_PROPS_STRING_0                0<br />#define USB_CFG_DESCR_PROPS_STRING_VENDOR           0<br />#define USB_CFG_DESCR_PROPS_STRING_PRODUCT          0<br />#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER    0<br />#define USB_CFG_DESCR_PROPS_HID                     0<br />#define USB_CFG_DESCR_PROPS_HID_REPORT              0<br />#define USB_CFG_DESCR_PROPS_UNKNOWN                 0<br /><br /><br />//#define usbMsgPtr_t unsigned short<br />#define usbMsgPtr_t char *<br />/* If usbMsgPtr_t is not defined, it defaults to 'uchar *'. We define it to<br /> * a scalar type here because gcc generates slightly shorter code for scalar<br /> * arithmetics than for pointer arithmetics. Remove this define for backward<br /> * type compatibility or define it to an 8 bit type if you use data in RAM only<br /> * and all RAM is below 256 bytes (tiny memory model in IAR CC).<br /> */<br /><br />/* ----------------------- Optional MCU Description ------------------------ */<br /><br />/* The following configurations have working defaults in usbdrv.h. You<br /> * usually don't need to set them explicitly. Only if you want to run<br /> * the driver on a device which is not yet supported or with a compiler<br /> * which is not fully supported (such as IAR C) or if you use a differnt<br /> * interrupt than INT0, you may have to define some of these.<br /> */<br />/* #define USB_INTR_CFG            MCUCR */<br />/* #define USB_INTR_CFG_SET        ((1 &lt;&lt; ISC00) | (1 &lt;&lt; ISC01)) */<br />/* #define USB_INTR_CFG_CLR        0 */<br />/* #define USB_INTR_ENABLE         GIMSK */<br />/* #define USB_INTR_ENABLE_BIT     INT0 */<br />/* #define USB_INTR_PENDING        GIFR */<br />/* #define USB_INTR_PENDING_BIT    INTF0 */<br />/* #define USB_INTR_VECTOR         INT0_vect */<br />/*<br />#define USB_INTR_CFG            MCUCR<br />#define USB_INTR_CFG_SET        ((1 &lt;&lt; ISC10) | (1 &lt;&lt; ISC11))<br />#define USB_INTR_CFG_CLR        0<br />#define USB_INTR_ENABLE         EIMSK<br />#define USB_INTR_ENABLE_BIT     INT1<br />#define USB_INTR_PENDING        EIFR<br />#define USB_INTR_PENDING_BIT    INTF1<br />#define USB_INTR_VECTOR         INT1_vect<br />*/<br />#endif /* __usbconfig_h_included__ */[/syntax]<br />potrzebuje przynajmniej kilku sekund na przesłanie tekstu i kilkukrotnego kliknięcia cmd_bk_on aby to zrobić czasami na ekranie też widzę dziwne znaczki ale nwm czy to slave coś dziwnego robi<br />atmega644p 16mhz, podesłać też kod slave'a dać jakiś przebieg z analizatora?<br />(ps nadal się z tym męczę)<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=22158">domson</a> — 8 wrz 2024, o 18:14</p><hr />
]]></content>
</entry>
</feed>