Path: csiph.com!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.bresnan.com!news.bresnan.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 03 Mar 2012 01:06:16 -0600 Date: Sat, 03 Mar 2012 00:06:09 -0700 From: GreyCloud User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 Newsgroups: comp.os.linux.advocacy,comp.os.linux.embedded Subject: Re: Reading the Riot Act To ARM's developers References: <4iah09-1p2.ln1@spankydtr.localhost.net> <87fwdzpbqe.fsf@bazspaz.fatphil.org> <87zkc4mlho.fsf@bazspaz.fatphil.org> <87aa3ymtwp.fsf@bazspaz.fatphil.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 73 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 184.166.182.172 X-Trace: sv3-afqaGTAn/CjBCieE3ig1ac7pZHAkZv9+Ghh7grlMNh3GUWbWhAIDfIF9/Naw7kVgqLMYhtyesX3p6sc!5O5WSe9uOO4JVpLuejvgLlVbktKDy7CnWsWeInbZxQDndvwi0yiEY1sMjKo6UJ1yW3Yg1kkt65rJ!1xSq+Gh2fW4zYkg= X-Complaints-To: abuse@bresnan.net X-DMCA-Complaints-To: abuse@bresnan.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3589 Xref: csiph.com comp.os.linux.advocacy:93478 comp.os.linux.embedded:186 On 3/2/2012 5:20 PM, 7 wrote: > Phil Carmody wrote: > > >>>>> Phil Carmody wrote: >>>>>>> #define INT_XMA (1<< 4) >>>>>>> #define ENABLE_RS232 SYSCON->INT |= INT_XMA >>>>>> >>>>>> Ewwww! Don't do that. >>>>>> >>>>>>> The problem I am having is what does that '4' mean. Is it 4 or 14 or >>>>>>> something else? I need a datasheet. Thats just crap programming. >>>>>>> >>>>>>> What I want to be able to do is >>>>>>> >>>>>>> #define ENABLED 1 >>>>>>> #define ENABLE_RS232_INTERRUPT SYSCON.INT.INT_XMA = ENABLED >>>>>> >>>>>> Ewww! Don't do that either. >>>>>> >>>>>> NACKed. >>>>> >>>>> By all means save us the laughs and >>>>> write one line of code to say what you would do. >>>> >>>> Well, even the mindless robotic conversion to >>>> >>>> #define ENABLE_RS232_INTERRUPT() do { SYSCON.INT.INT_XMA = ENABLED; } >>>> #while(0) >>>> >>>> would be better than what you had. >>>> >>>> Phil >>> >>> I would prefer three lines: >>> >>> static inline void enable_rs232_interrupt(void) { >>> SYSCON.INT.INT_XMA = ENABLED; >>> } >> >> Whilst it is a sensible assumption to presume that SYSCON is visible at >> the point of definition of the helper, it is by no means guaranteed, as >> it's not obvious from the above, nor necessary for the macro to work - >> you have to bear in mind the kind of code we're already dealing with. > > > Waaaat? > > > Lets say you define all the hardware in hardware.h. > Then at the beginning you do this: > > > #ifndef HARDWARE_H > #define HARDWARE_H > // filename hardware.h > > #include "your_CPU's_CMSIS_header_file.h" > > #define ENABLED 1 > #define ENABLE_RS232_INTERRUPT SYSCON.INT.INT_XMA = ENABLED > > // end of hardware.h > #endif > > Now whenever you do a include "hardware.h" to get at > ENABLE_RS232_INTERRUPT, you automatically have > access to whatever SYSCON has been set up as in the CMSIS file. > > So far so good. Seems a reasonable start. Tho I don't know what is inside the CMSIS header file.