summaryrefslogtreecommitdiff
path: root/nuttx/drivers/analog
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-15 16:39:06 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-15 16:39:06 +0000
commit35efe997b4ea5352c341b8a1e8661ac83d1bc5ae (patch)
tree6f95e16854e297c82ed428daed9959ac41f5d86e /nuttx/drivers/analog
parent27c16edcc1befe9afeb4a1996c3b22bc9acd8380 (diff)
downloadpx4-nuttx-35efe997b4ea5352c341b8a1e8661ac83d1bc5ae.tar.gz
px4-nuttx-35efe997b4ea5352c341b8a1e8661ac83d1bc5ae.tar.bz2
px4-nuttx-35efe997b4ea5352c341b8a1e8661ac83d1bc5ae.zip
More STM32 DAC driver logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4186 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/analog')
-rw-r--r--nuttx/drivers/analog/dac.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/nuttx/drivers/analog/dac.c b/nuttx/drivers/analog/dac.c
index a5f4c1473..b283a5bf5 100644
--- a/nuttx/drivers/analog/dac.c
+++ b/nuttx/drivers/analog/dac.c
@@ -296,17 +296,17 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, size_t
*/
if (buflen % 5 ==0 )
- msglen=5;
+ msglen=5;
else if (buflen % 4 ==0 )
- msglen=4;
+ msglen=4;
else if (buflen % 3 ==0 )
- msglen=3;
+ msglen=3;
else if (buflen % 2 ==0 )
- msglen=2;
+ msglen=2;
else if (buflen == 1)
- msglen=1;
+ msglen=1;
else
- msglen=5;
+ msglen=5;
while ((buflen - nsent) >= msglen )
{
@@ -369,35 +369,36 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, size_t
/* We get here if there is space at the end of the FIFO. Add the new
* CAN message at the tail of the FIFO.
*/
- if(msglen==5)
+
+ if (msglen==5)
{
- msg = (FAR struct dac_msg_s *)&buffer[nsent];
- memcpy(&fifo->af_buffer[fifo->af_tail], msg, msglen);
+ msg = (FAR struct dac_msg_s *)&buffer[nsent];
+ memcpy(&fifo->af_buffer[fifo->af_tail], msg, msglen);
}
else if(msglen == 4)
{
- fifo->af_buffer[fifo->af_tail].am_channel=buffer[nsent];
- fifo->af_buffer[fifo->af_tail].am_data=*(uint32_t *)&buffer[nsent];
- fifo->af_buffer[fifo->af_tail].am_data&=0xffffff00;
- }
+ fifo->af_buffer[fifo->af_tail].am_channel=buffer[nsent];
+ fifo->af_buffer[fifo->af_tail].am_data=*(uint32_t *)&buffer[nsent];
+ fifo->af_buffer[fifo->af_tail].am_data&=0xffffff00;
+ }
else if(msglen == 3)
{
- fifo->af_buffer[fifo->af_tail].am_channel=buffer[nsent];
- fifo->af_buffer[fifo->af_tail].am_data=(*(uint16_t *)&buffer[nsent+1]);
- fifo->af_buffer[fifo->af_tail].am_data<<=16;
- }
+ fifo->af_buffer[fifo->af_tail].am_channel=buffer[nsent];
+ fifo->af_buffer[fifo->af_tail].am_data=(*(uint16_t *)&buffer[nsent+1]);
+ fifo->af_buffer[fifo->af_tail].am_data<<=16;
+ }
else if(msglen == 2)
{
- fifo->af_buffer[fifo->af_tail].am_channel=0;
- fifo->af_buffer[fifo->af_tail].am_data=(*(uint16_t *)&buffer[nsent]);
- fifo->af_buffer[fifo->af_tail].am_data<<=16;
- }
+ fifo->af_buffer[fifo->af_tail].am_channel=0;
+ fifo->af_buffer[fifo->af_tail].am_data=(*(uint16_t *)&buffer[nsent]);
+ fifo->af_buffer[fifo->af_tail].am_data<<=16;
+ }
else if(msglen == 1)
{
- fifo->af_buffer[fifo->af_tail].am_channel=0;
- fifo->af_buffer[fifo->af_tail].am_data=buffer[nsent];
- fifo->af_buffer[fifo->af_tail].am_data<<=24;
- }
+ fifo->af_buffer[fifo->af_tail].am_channel=0;
+ fifo->af_buffer[fifo->af_tail].am_data=buffer[nsent];
+ fifo->af_buffer[fifo->af_tail].am_data<<=24;
+ }
/* Increment the tail of the circular buffer */
fifo->af_tail = nexttail;