<?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=23&amp;t=3873&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2013-08-16T13:49:09+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=23&amp;t=3873&amp;mode</id>
<entry>
<author><name><![CDATA[aaadamw]]></name></author>
<updated>2013-08-16T13:49:09+01:00</updated>
<published>2013-08-16T13:49:09+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45900#p45900</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45900#p45900"/>
<title type="html"><![CDATA[Re: Uproszczenie migania diodami]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45900#p45900"><![CDATA[
<div class="quotetitle">GwynBleidD napisał(a):</div><div class="quotecontent"><br />Właściwie niepotrzebne są w tej postaci definicje LED1-LED8<br /></div><br />no faktycznie <img src="https://forum.atnel.pl/images/smilies/icon_e_biggrin.gif" alt=":D" title="Bardzo szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=360">aaadamw</a> — 16 sie 2013, o 13:49</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[aaadamw]]></name></author>
<updated>2013-08-16T12:37:52+01:00</updated>
<published>2013-08-16T12:37:52+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45894#p45894</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45894#p45894"/>
<title type="html"><![CDATA[Re: Uproszczenie migania diodami]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45894#p45894"><![CDATA[
Z tym że niestety na samych  makrach wszystkiego się nie da zrobić. Ja na tych diodach chcę wyświetlać wartość jakiejś zmiennej(np. temperatura), więc chyba mój sposób będzie do tego celu dobry. <br />Zgodnie z Twoimi uwagami zmieniłem tylko sposób wyłuskiwania adresu portów. <br />I mała poprawka Twojej poprawki w definicji typu strukturalnego dodałem 'volatile' do zmiennej przechowującej adres portu.<br />ostatecznie wyszło tak:<br />[syntax=c]#define LED1 (1&lt;&lt;PD4)<br />#define LED2 (1&lt;&lt;PD5)<br />#define LED3 (1&lt;&lt;PD7)<br />#define LED4 (1&lt;&lt;PB0)<br />#define LED5 (1&lt;&lt;PA3)<br />#define LED6 (1&lt;&lt;PA2)<br />#define LED7 (1&lt;&lt;PA1)<br />#define LED8 (1&lt;&lt;PA0)<br />#define MIGAJ_LED(a) (*diody&#91;a-1&#93;.prt)^=diody&#91;a-1&#93;.pn;<br />#define ZGAS_LED(a) (*diody&#91;a-1&#93;.prt)|=diody&#91;a-1&#93;.pn;<br />#define ZAPAL_LED(a) (*diody&#91;a-1&#93;.prt)&amp;=~(diody&#91;a-1&#93;.pn);<br />typedef struct {<br />volatile uint8_t *prt;<br />uint8_t pn;<br />}T_DIODY;<br />T_DIODY diody&#91;8&#93;={<br />{&amp;PORTD,LED1},<br />{&amp;PORTD,LED2},<br />{&amp;PORTD,LED3},<br />{&amp;PORTB,LED4},<br />{&amp;PORTA,LED5},<br />{&amp;PORTA,LED6},<br />{&amp;PORTA,LED7},<br />{&amp;PORTA,LED8},<br />};[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=360">aaadamw</a> — 16 sie 2013, o 12:37</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[aaadamw]]></name></author>
<updated>2013-08-15T17:39:53+01:00</updated>
<published>2013-08-15T17:39:53+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45834#p45834</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45834#p45834"/>
<title type="html"><![CDATA[Re: Uproszczenie migania diodami]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45834#p45834"><![CDATA[
Faktycznie można prościej... ale przynajmniej się czegoś nauczyłem.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=360">aaadamw</a> — 15 sie 2013, o 17:39</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[aaadamw]]></name></author>
<updated>2013-08-15T14:30:46+01:00</updated>
<published>2013-08-15T14:30:46+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45822#p45822</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45822#p45822"/>
<title type="html"><![CDATA[Uproszczenie migania diodami]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=3873&amp;p=45822#p45822"><![CDATA[
witam,<br />może ktoś zna lepszy pomysł na to co za chwilę opiszę, ale może mój sposób też się komuś przyda.<br />Miałem potrzebę sterowania 8 diodami w stylu punktu przesuwającego się np od lewej do prawej. Diody są podłączone do różnych portów, więc to trochę komplikuje sprawę. Wymyśliłem więc coś takiego:<br />[syntax=c]#define adres_porta 0x22<br />#define adres_portb 0x25<br />#define adres_portd 0x2b<br />#define LED1 (1&lt;&lt;PD4)<br />#define LED2 (1&lt;&lt;PD5)<br />#define LED3 (1&lt;&lt;PD7)<br />#define LED4 (1&lt;&lt;PB0)<br />#define LED5 (1&lt;&lt;PA3)<br />#define LED6 (1&lt;&lt;PA2)<br />#define LED7 (1&lt;&lt;PA1)<br />#define LED8 (1&lt;&lt;PA0)<br />#define MIGAJ_LED(a) (*(volatile uint8_t *)(diody&#91;a-1&#93;.prt))^=diody&#91;a-1&#93;.pn;<br />#define ZGAS_LED(a) (*(volatile uint8_t *)(diody&#91;a-1&#93;.prt))|=diody&#91;a-1&#93;.pn;<br />#define ZAPAL_LED(a) (*(volatile uint8_t *)(diody&#91;a-1&#93;.prt))&amp;=~(diody&#91;a-1&#93;.pn);<br />typedef struct {<br />uint16_t prt;<br />uint8_t pn;<br />}T_DIODY;<br />T_DIODY diody&#91;8&#93;={<br />{adres_portd,LED1},<br />{adres_portd,LED2},<br />{adres_portd,LED3},<br />{adres_portb,LED4},<br />{adres_porta,LED5},<br />{adres_porta,LED6},<br />{adres_porta,LED7},<br />{adres_porta,LED8},<br />};[/syntax]<br /><br />dzięki temu można sterować diodami w bardzo prosty sposób:<br />[syntax=c]for(uint8_t i=1;i&lt;9;i++){<br /><br />ZAPAL_LED(i);<br />_delay_ms(300);<br />ZGAS_LED(i);<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=360">aaadamw</a> — 15 sie 2013, o 14:30</p><hr />
]]></content>
</entry>
</feed>