<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-2"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><title>Re: pole bitového pole v C</title><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"Formátovaný v HTML Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Text bubliny Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;}
span.FormtovanvHTMLChar
        {mso-style-name:"Formátovaný v HTML Char";
        mso-style-priority:99;
        mso-style-link:"Formátovaný v HTML";
        font-family:Consolas;
        color:black;}
span.TextbublinyChar
        {mso-style-name:"Text bubliny Char";
        mso-style-priority:99;
        mso-style-link:"Text bubliny";
        font-family:"Tahoma","sans-serif";
        color:black;}
span.StylE-mailovZprvy22
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.StylE-mailovZprvy23
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.StylE-mailovZprvy24
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.StylE-mailovZprvy25
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.StylE-mailovZprvy26
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.StylE-mailovZprvy27
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.StylE-mailovZprvy28
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.StylE-mailovZprvy29
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=CS link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Nechám to tak. Ale ty 3bytiky co by se daly ušetřit mě fakt drásají. </span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>L</span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Díky.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> hw-list-bounces@list.hw.cz [mailto:hw-list-bounces@list.hw.cz] <b>On Behalf Of </b>Jaroslav Buchta<br><b>Sent:</b> Saturday, January 12, 2013 10:17 PM<br><b>To:</b> HW-news<br><b>Subject:</b> Re: pole bitového pole v C<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>To takhle asi nepujde. Asi by bylo cestou definovat lokalni promennou typu _SetBitPole, inicializovat a pouzit, rozumny prekladac to zoptimalizuje a pouzije jen registr a bude to OK.<br>Abych rekl pravdu, ja bych takove slozite konstrukce nepouzival a bud pouzil ve funkci 2 parametry nebo jeden a nejaka makra na slozeni hodnot do parametru skrz posuvy a bitove OR. V C++ by to bylo jine kafe, ale u MCU s klasickym C je to IMHO trosku kanon na vrabce.<br><br>Dne 12.1.2013 22:11, Miroslav Draxal napsal(a):<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Vlastně obklikou to dělám takhle</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> tmp.value = (24 - CisloSekce) | 0x40;</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> VentilSet (tmp);</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Chtěl bych</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> VentilSet ((24 - CisloSekce) | 0x40);</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> <a href="mailto:hw-list-bounces@list.hw.cz">hw-list-bounces@list.hw.cz</a> [<a href="mailto:hw-list-bounces@list.hw.cz">mailto:hw-list-bounces@list.hw.cz</a>] <b>On Behalf Of </b>Jaroslav Buchta<br><b>Sent:</b> Saturday, January 12, 2013 9:44 PM<br><b>To:</b> HW-news<br><b>Subject:</b> Re: pole bitového pole v C</span><o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><div><p class=MsoNormal>Ja proste na tyhle prevody jdu pres ukazatele, takze bych to udelal zase takhle (nezkouseno)<br><br>VentilSet (*((_SetBitPole*)&TMP));<br><br>Proste se vezme adresa promenne TMP operatorem &, ukazatel na cokoli jde pretypovat na ukazatel na cokoli jineho, cili i na union a pak se operatorem dereference * zase ziska objekt na odkazovane adrese (uz pretypovany). Mozna to jde i jednoduseji, ale ja takhle prevadim i typy z neznaminkovych na znamenkove, napr. v komunikacnich paketech, kdyz UINT uvnitr obsahuje hodnotu se znamenkem, napr.: float fTempSecIn = (float)*(short*)&ProcImgRO.r.tempSecInp100; <br><br><br>Dne 12.1.2013 21:34, Miroslav Draxal napsal(a):<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hmm, přiznávám, že tomu nehovím, neumím to přečíst. Nic. Ráno se k tomu vrátím, a budu se to snažit pochopit. Pro dnešek ještě jednu věc.</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Mějme podprogram</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>void VentilSet (_SetBitPole CisloVentilu)</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>kde </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>typedef union {</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> char value;</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> struct {</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> unsigned CisloBitu : 6;</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> unsigned SetClr : 1;</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> } bits;</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>} _SetBitPole;</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Pokud budu mí char TMP</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Jak to dostanu do volání toho podprogramu.</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>VentilSet(TMP) </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Stále se jedná o 1byt.</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Je mi jasné že na začátku vytvořit TMP jako _ SetBitPole</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Přetypování char na union nejde. Jak na to? Míra</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> <a href="mailto:hw-list-bounces@list.hw.cz">hw-list-bounces@list.hw.cz</a> [<a href="mailto:hw-list-bounces@list.hw.cz">mailto:hw-list-bounces@list.hw.cz</a>] <b>On Behalf Of </b>Jaroslav Buchta<br><b>Sent:</b> Saturday, January 12, 2013 8:27 PM<br><b>To:</b> HW-news<br><b>Subject:</b> Re: pole bitového pole v C</span><o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><div><p class=MsoNormal>Takhle mi to AVR C sezere: (jeste jsem musel doplnit zavorky)<br><br>char byt;<br><br>typedef union bytX<br><br>{<br><br> char value;<br><br> unsigned bit0 : 1;<br><br>}_byt;<br><br>int main (void)<br>{<br> <br> (*((_byt*)&byt)).bit0 = 1;<br><br><br><br><br><o:p></o:p></p></div><p class=MsoNormal><br><br>__________ Informace od ESET NOD32 Antivirus, verze databaze 7887 (20130112) __________<br><br>Tuto zpravu proveril ESET NOD32 Antivirus.<br><br><a href="http://www.eset.cz">http://www.eset.cz</a><br><br><br><br><br><o:p></o:p></p><pre>_______________________________________________<o:p></o:p></pre><pre>HW-list mailing list - sponsored by <a href="http://www.HW.cz">www.HW.cz</a><o:p></o:p></pre><pre><a href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a><o:p></o:p></pre><pre><a href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a><o:p></o:p></pre></blockquote><p class=MsoNormal><br><br><br>__________ Informace od ESET NOD32 Antivirus, verze databaze 7887 (20130112) __________<br><br>Tuto zpravu proveril ESET NOD32 Antivirus.<br><br><a href="http://www.eset.cz">http://www.eset.cz</a><o:p></o:p></p><p class=MsoNormal><br><br>__________ Informace od ESET NOD32 Antivirus, verze databaze 7887 (20130112) __________<br><br>Tuto zpravu proveril ESET NOD32 Antivirus.<br><br><a href="http://www.eset.cz">http://www.eset.cz</a><br><br><br><br><o:p></o:p></p><pre>_______________________________________________<o:p></o:p></pre><pre>HW-list mailing list - sponsored by <a href="http://www.HW.cz">www.HW.cz</a><o:p></o:p></pre><pre><a href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a><o:p></o:p></pre><pre><a href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a><o:p></o:p></pre></blockquote><p class=MsoNormal><br><br><br>__________ Informace od ESET NOD32 Antivirus, verze databaze 7887 (20130112) __________<br><br>Tuto zpravu proveril ESET NOD32 Antivirus.<br><br><a href="http://www.eset.cz">http://www.eset.cz</a><o:p></o:p></p></div> <BR>
<BR>
__________ Informace od ESET NOD32 Antivirus, verze databaze 7887 (20130112) __________<BR>
<BR>
Tuto zpravu proveril ESET NOD32 Antivirus.<BR>
<BR>
<A HREF="http://www.eset.cz">http://www.eset.cz</A><BR>
</body></html>