[Armadeus-commitlog] armadeus branch, master, updated. latestrelease-141-g9747336
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2009-11-01 11:20:14
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 97473365d71fb109f9919bda9e3d1b99afdacec5 (commit)
via 67bb77e038555dd0f7749cfde1d3993ae7a1efdc (commit)
via 1ce8527a7e8cb160c997a6c67e1b40d32b3ef5c5 (commit)
via 11e6911536d90e7b2d8fc0d231db1758a96ee91b (commit)
via 269c1882d60a7034917fb79f367cd5dec3e774c7 (commit)
from 316c31fd75f2895c67ca21ae9ace86e0ddecfa62 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 97473365d71fb109f9919bda9e3d1b99afdacec5
Merge: 67bb77e038555dd0f7749cfde1d3993ae7a1efdc 316c31fd75f2895c67ca21ae9ace86e0ddecfa62
Author: Julien Boibessot <jul...@ar...>
Date: Sun Nov 1 12:19:33 2009 +0100
Merge branch 'master' of ssh://artemys@armadeus.git.sourceforge.net/gitroot/armadeus/armadeus
commit 67bb77e038555dd0f7749cfde1d3993ae7a1efdc
Author: Julien Boibessot <jul...@ar...>
Date: Sun Nov 1 12:18:49 2009 +0100
[DEBUG] imxssi doesn't require libpow to compile
commit 1ce8527a7e8cb160c997a6c67e1b40d32b3ef5c5
Author: Julien Boibessot <jul...@ar...>
Date: Sat Oct 31 22:39:10 2009 +0100
Add some .gitignore files
commit 11e6911536d90e7b2d8fc0d231db1758a96ee91b
Author: Julien Boibessot <jul...@ar...>
Date: Sat Oct 31 22:35:29 2009 +0100
[TOOLS] Simplify setDAC tool sources
commit 269c1882d60a7034917fb79f367cd5dec3e774c7
Author: Julien Boibessot <jul...@ar...>
Date: Thu Oct 29 15:47:10 2009 +0100
[TOOLS] ad9889ctrl: Cleanup + indentation
-----------------------------------------------------------------------
Summary of changes:
buildroot/package/ad9889ctrl/ad9889.mk | 5 +-
target/linux/debug/imxssi/configure.ac | 2 -
target/{demos => packages}/.gitignore | 0
target/packages/ad9889ctrl/ad9889ctrl.c | 177 +++++++++++++++----------------
target/packages/max5821ctrl/.gitignore | 1 +
target/packages/max5821ctrl/max5821.h | 6 +-
target/packages/max5821ctrl/setDAC.c | 120 +++++++++------------
7 files changed, 143 insertions(+), 168 deletions(-)
copy target/{demos => packages}/.gitignore (100%)
create mode 100644 target/packages/max5821ctrl/.gitignore
diff --git a/buildroot/package/ad9889ctrl/ad9889.mk b/buildroot/package/ad9889ctrl/ad9889.mk
index 6ee401e..6ff0cef 100644
--- a/buildroot/package/ad9889ctrl/ad9889.mk
+++ b/buildroot/package/ad9889ctrl/ad9889.mk
@@ -1,6 +1,6 @@
#############################################################
#
-# ad9889 tool
+# ad9889 control tool
#
#############################################################
@@ -12,12 +12,11 @@ AD9889CTRL_BINARY:=ad9889ctrl
AD9889CTRL_TARGET_BINARY:=usr/bin/ad9889ctrl
$(AD9889CTRL_DIR)/ad9889ctrl.c:
- set
mkdir -p $(AD9889CTRL_DIR)/
cp $(AD9889CTRL_SOURCE)/* $(AD9889CTRL_DIR)/
$(AD9889CTRL_DIR)/$(AD9889CTRL_BINARY): $(AD9889CTRL_DIR)/ad9889ctrl.c $(AD9889CTRL_DIR)/ad9889ctrl.h
- $(TARGET_CONFIGURE_OPTS) $(MAKE) CC=$(TARGET_CC) -C $(AD9889CTRL_DIR)
+ $(MAKE) CC=$(TARGET_CC) -C $(AD9889CTRL_DIR)
$(TARGET_DIR)/$(AD9889CTRL_TARGET_BINARY): $(AD9889CTRL_DIR)/$(AD9889CTRL_BINARY)
install -D $< $@
diff --git a/target/linux/debug/imxssi/configure.ac b/target/linux/debug/imxssi/configure.ac
index 50afb78..65f49e1 100644
--- a/target/linux/debug/imxssi/configure.ac
+++ b/target/linux/debug/imxssi/configure.ac
@@ -9,6 +9,4 @@ AC_CONFIG_FILES([
Makefile
])
-AC_SEARCH_LIBS(pow, m)
-
AC_OUTPUT
diff --git a/target/demos/.gitignore b/target/packages/.gitignore
similarity index 100%
copy from target/demos/.gitignore
copy to target/packages/.gitignore
diff --git a/target/packages/ad9889ctrl/ad9889ctrl.c b/target/packages/ad9889ctrl/ad9889ctrl.c
index 3784474..246e95d 100644
--- a/target/packages/ad9889ctrl/ad9889ctrl.c
+++ b/target/packages/ad9889ctrl/ad9889ctrl.c
@@ -1,7 +1,7 @@
/*
** THE ARMADEUS PROJECT
**
-** Copyright (C) year The source forge armadeus project team
+** Copyright (C) 2009 The source forge armadeus project team
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** ad9889ctrl: manage the Svideo controller AD9889
+** ad9889ctrl: manage the AD9889 Video controller
**
** authors: th...@us..., jo...@ar...
*/
@@ -45,15 +45,15 @@
/* MENU */
void usage()
{
- printf ("\nad9889ctrl utility ver %s Armadeus\n", VERSION);
- printf ("q: quit\n");
- printf ("i: initialize\n");
- printf ("m: modify\n");
- printf ("d: dump AD9889 registers\n");
- printf ("e: dump EDID registers\n");
- printf ("s: save\n");
- printf ("l: load\n");
- printf ("other: menu\n");
+ printf("\nad9889ctrl utility ver %s Armadeus\n", VERSION);
+ printf("q: quit\n");
+ printf("i: initialize\n");
+ printf("m: modify\n");
+ printf("d: dump AD9889 registers\n");
+ printf("e: dump EDID registers\n");
+ printf("s: save\n");
+ printf("l: load\n");
+ printf("other: this menu\n");
}
static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
@@ -68,19 +68,19 @@ static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
return ioctl(file,I2C_SMBUS,&args);
}
-/* Read a byte on the I2C bus
- This is done by writing the register address
+/* Read a byte on the I2C bus
+ This is done by writing the register address
we want to access and then by reading this register
@param fd: file descriptor of the device
@param reg: register to access
@param buf: buffer used to store the result
@return : -1 in case of error otherwise 0
*/
-int read_byte( int fd, unsigned char dev, unsigned char reg, unsigned char *buf )
-{
+int read_byte(int fd, unsigned char dev, unsigned char reg, unsigned char *buf)
+{
union i2c_smbus_data data;
- // configure I2C_SLAVE
+ /* configure I2C_SLAVE */
if ( ioctl(fd ,I2C_SLAVE, dev) < 0){
perror("Ioctl error: ");
return -1;
@@ -108,15 +108,15 @@ int write_byte(int fd, unsigned char dev, unsigned char reg, unsigned char value
data.byte = value;
#ifdef DEBUG_AD9889
- printf("write chip %02X ref %02X value %02X\n", dev, reg, value);
+ printf("write chip %02X ref %02X value %02X\n", dev, reg, value);
#endif
- // configure I2C_SLAVE
- if ( ioctl(fd ,I2C_SLAVE, dev) < 0){
+ /* configure I2C_SLAVE */
+ if (ioctl(fd, I2C_SLAVE, dev) < 0) {
perror("Ioctl error: ");
return -1;
}
- return i2c_smbus_access(fd,I2C_SMBUS_WRITE,reg,
+ return i2c_smbus_access(fd, I2C_SMBUS_WRITE, reg,
I2C_SMBUS_BYTE_DATA, &data);
return 0;
@@ -126,12 +126,12 @@ int write_byte(int fd, unsigned char dev, unsigned char reg, unsigned char value
@param string: string to dump
@param destFile: file in which to write
*/
- void dump2Output(char* string, FILE* destFile)
+void dump2Output(char* string, FILE* destFile)
{
- if( destFile == NULL )
+ if (destFile == NULL)
printf("%s", string);
else
- fprintf(destFile,"%s", string);
+ fprintf(destFile, "%s", string);
}
/* dump the register values on the screen if destFile is NULL or in a file
@@ -145,39 +145,37 @@ void dump(int fd, FILE* destFile)
char dumpString[MAX_DUMP_LINE];
unsigned char dev = AD9889_I2C_SLAVE_ADDR;
- if( destFile == NULL )
+ if (destFile == NULL)
printf("Dev:Ad:Va\tDev:Ad:Va\tDev:Ad:Va\tDev:Ad:Va\n");
- // dumping main registers
- for( i = 0; i<(0xd0/4); i++ ){
- for( j = 0; j<4; j++ ){
+ /* dumping main registers */
+ for (i = 0; i<(0xd0/4); i++) {
+ for (j = 0; j<4; j++) {
address = i*4+j;
- if( !read_byte( fd, dev, address, buf ) ){
+ if (!read_byte(fd, dev, address, buf)) {
sprintf( dumpString, " %02X:%02X:%02X\t",
AD9889_I2C_SLAVE_ADDR, address, buf[0] );
- dump2Output( dumpString, destFile );
+ dump2Output(dumpString, destFile);
}
}
- dump2Output( "\n", destFile );
+ dump2Output("\n", destFile);
}
- // dumping secondary registers
- if( !read_byte( fd, AD9889_I2C_SLAVE_ADDR, 0xCF, buf ) ) {
+ /* dumping secondary registers */
+ if (!read_byte(fd, AD9889_I2C_SLAVE_ADDR, 0xCF, buf)) {
dev = buf[0]>>1;
- for( address = 0; address<0x1F; address++ ){
- if( !read_byte( fd, dev, address, buf ) ){
- sprintf( dumpString, " %02X:%02X:%02X\t",
- dev, address, buf[0] );
- dump2Output( dumpString, destFile );
+ for (address = 0; address<0x1F; address++) {
+ if (!read_byte( fd, dev, address, buf)) {
+ sprintf(dumpString, " %02X:%02X:%02X\t",
+ dev, address, buf[0]);
+ dump2Output(dumpString, destFile);
}
if ((3 == address % 4) && (0x1E != address)) {
- dump2Output( "\n", destFile );
+ dump2Output("\n", destFile);
}
}
- dump2Output( "\n", destFile );
-
+ dump2Output("\n", destFile);
}
-
/*
if( !read_byte( fd, DAC_TRIMMING_CMD, buf ) ){
sprintf( dumpString, "%02X:%02X\t", DAC_TRIMMING_CMD, buf[0] );
@@ -200,30 +198,28 @@ void dump(int fd, FILE* destFile)
*/
void dumpedid(int fd, FILE* destFile)
{
- int i,j, address;
+ int address;
unsigned char buf[2];
char dumpString[MAX_DUMP_LINE];
unsigned char dev = AD9889_I2C_SLAVE_ADDR;
- if( destFile == NULL )
+ if (destFile == NULL)
printf("Dev:Ad:Va\tDev:Ad:Va\tDev:Ad:Va\tDev:Ad:Va\n");
-
- // dumping EBID memory
- if( !read_byte( fd, AD9889_I2C_SLAVE_ADDR, 0x43, buf ) ) {
+ /* dumping EDID memory */
+ if (!read_byte( fd, AD9889_I2C_SLAVE_ADDR, 0x43, buf )) {
dev = buf[0]>>1;
- for( address = 0; address<0x100; address++ ){
- if( !read_byte( fd, dev, address, buf ) ){
+ for (address = 0; address<0x100; address++) {
+ if (!read_byte( fd, dev, address, buf )) {
sprintf( dumpString, " %02X:%02X:%02X\t",
dev, address, buf[0] );
- dump2Output( dumpString, destFile );
+ dump2Output(dumpString, destFile);
}
if ((3 == address % 4) && (0xFF != address)) {
- dump2Output( "\n", destFile );
+ dump2Output("\n", destFile);
}
}
- dump2Output( "\n", destFile );
-
+ dump2Output("\n", destFile);
}
/*
if( !read_byte( fd, DAC_TRIMMING_CMD, buf ) ){
@@ -245,7 +241,7 @@ void dumpedid(int fd, FILE* destFile)
@param fd: file descriptor of the AD9889
@param fileName: file containing the values. If "" then the name has to be entered
*/
-void load( int fd, char* fileName )
+void load(int fd, char* fileName)
{
char line[MAX_DUMP_LINE];
char tempFileName[MAX_DUMP_LINE];
@@ -255,37 +251,37 @@ void load( int fd, char* fileName )
int val1, val2, val3, val4;
int nb;
- if( strlen(fileName) == 0 ){
+ if (strlen(fileName) == 0) {
printf("Enter file name: ");
fgets (tempFileName, sizeof(tempFileName), stdin);
- tempFileName[strlen(tempFileName)-1] = '\0'; //suppress \n
+ tempFileName[strlen(tempFileName)-1] = '\0'; /* suppress \n */
}
- else{
+ else {
strcpy(tempFileName,fileName);
}
- if ((fd_conf = fopen(tempFileName,"r")) == NULL){
+ if ((fd_conf = fopen(tempFileName,"r")) == NULL) {
perror("Open error: ");
exit (1);
}
- while(fgets(line, MAX_DUMP_LINE, fd_conf) != NULL){
+ while (fgets(line, MAX_DUMP_LINE, fd_conf) != NULL) {
nb = sscanf(line,"%2X%*c%2X%*c%2X%2X%*c%2X%*c%2X%2X%*c%2X%*c%2X%2X%*c%2X%*c%2X",
&dev1,&addr1,&val1,&dev2,&addr2,&val2,
&dev3,&addr3,&val3,&dev4,&addr4,&val4 );
- if(nb>=3)
+ if (nb >= 3)
write_byte (fd, dev1, addr1, val1);
- if(nb>=6)
+ if (nb >= 6)
write_byte (fd, dev2, addr2, val2);
- if(nb>=9)
+ if (nb >= 9)
write_byte (fd, dev3, addr3, val3);
- if(nb>=12)
+ if (nb >= 12)
write_byte (fd, dev4, addr4, val4);
}
/* power down to reset the dac after parameter changing*/
// write_byte (fd, POWER_STATE_CMD, 0xFF);
/* power on the dac after parameter changing*/
// write_byte (fd, POWER_STATE_CMD, 0x00);
- if(fd_conf != NULL)
+ if (fd_conf != NULL)
fclose(fd_conf);
}
@@ -296,19 +292,19 @@ int ad9889_init(int fd)
int i= 10000;
while ((!hpd) && (i-- >0)) {
- if( !read_byte( fd, AD9889_I2C_SLAVE_ADDR, 0x42, buf ) )
- {
+ if (!read_byte(fd, AD9889_I2C_SLAVE_ADDR, 0x42, buf)) {
hpd = buf[0]&0x40;
- }
- else printf("hpd read failed\n");
+ } else {
+ printf("hpd read failed\n");
+ }
}
- if (hpd){
+ if (hpd) {
printf("hpd active.\n");
} else {
printf("hpd not active, force powerup.\n");
}
- write_byte (fd, AD9889_I2C_SLAVE_ADDR, 0x41, 0x10);
+ write_byte(fd, AD9889_I2C_SLAVE_ADDR, 0x41, 0x10);
return 0;
}
@@ -322,45 +318,43 @@ int main(int argc, char *argv[])
int regValue;
char* bus = "/dev/i2c-1";
- if ( argc >2 ){ // too many args
+ if (argc >2 ) { /* too many args */
usage();
exit(1);
- } else if ( argc == 2 ){ // i2c bus
+ } else if (argc == 2) { /* i2c bus */
bus = argv[1];
}
-
- // open I2C /dev
- if ((fd = open(bus,O_RDWR)) < 0){
+ /* open I2C /dev */
+ if ((fd = open(bus,O_RDWR)) < 0) {
perror("Open error: ");
exit (1);
}
- // configure I2C_SLAVE
- if ( ioctl(fd ,I2C_SLAVE, AD9889_I2C_SLAVE_ADDR) < 0){
+ /* configure I2C_SLAVE */
+ if (ioctl(fd ,I2C_SLAVE, AD9889_I2C_SLAVE_ADDR) < 0) {
perror("Ioctl error: ");
exit (1);
}
- // check AD9889 presence
- if( !read_byte( fd, AD9889_I2C_SLAVE_ADDR, CHIP_REVISION, buf ) ){
- if ( (AD9889_MAX_REV < buf[0] )){
+ /* check AD9889 presence */
+ if (!read_byte( fd, AD9889_I2C_SLAVE_ADDR, CHIP_REVISION, buf)) {
+ if ((AD9889_MAX_REV < buf[0])) {
printf("AD9889 not recognized. Exit\n");
exit(1);
}
- }
- else {
+ } else {
printf("AD9889 not found. Exit\n");
exit(1);
}
usage();
- while(1){
+ while(1) {
fgets(string,sizeof(string),stdin);
- if(string[0] == 'q') { // Exit
+ if(string[0] == 'q') { /* Exit */
exit(0);
}
- else if (string[0] == 'm') { // Modify registers
+ else if (string[0] == 'm') { /* Modify registers */
int dev;
printf("chip addr (hex without 0x)(ex 39): ");
fgets(string,sizeof(string),stdin);
@@ -373,26 +367,26 @@ int main(int argc, char *argv[])
sscanf(string,"%2x", ®Value);
write_byte (fd, dev, regAddr, regValue);
}
- else if (string[0] == 'd') { // Dump to screen
+ else if (string[0] == 'd') { /* Dump to screen */
dump(fd,fd_conf);
}
- else if (string[0] == 'e') { // Dump to screen
+ else if (string[0] == 'e') { /* Dump to screen */
dumpedid(fd,NULL);
}
- else if (string[0] == 's') { // Save to file
+ else if (string[0] == 's') { /* Save to file */
if ((fd_conf = fopen(CONF_FILE,"w")) < 0) {
perror("Open error: ");
exit (1);
}
dump(fd,fd_conf);
- if(fd_conf != NULL) {
+ if (fd_conf != NULL) {
fclose(fd_conf);
}
}
- else if (string[0] == 'l') { // load from file
+ else if (string[0] == 'l') { /* load from file */
load(fd,"");
}
- else if (string[0] == 'i') { // init ad9889
+ else if (string[0] == 'i') { /* init ad9889 */
printf("initialize...\n");
ad9889_init(fd);
} else {
@@ -400,9 +394,10 @@ int main(int argc, char *argv[])
}
};
- if(fd >= 0) {
+ if (fd >= 0) {
close(fd);
}
exit (0);
}
+
diff --git a/target/packages/max5821ctrl/.gitignore b/target/packages/max5821ctrl/.gitignore
new file mode 100644
index 0000000..5eafa2b
--- /dev/null
+++ b/target/packages/max5821ctrl/.gitignore
@@ -0,0 +1 @@
+setDAC
diff --git a/target/packages/max5821ctrl/max5821.h b/target/packages/max5821ctrl/max5821.h
index 0d9fda9..14e7b09 100644
--- a/target/packages/max5821ctrl/max5821.h
+++ b/target/packages/max5821ctrl/max5821.h
@@ -52,7 +52,7 @@
#define POWER_CTRL_SELECTED 0x1
#define POWER_CTRL_UNSELECTED 0x0
-#define MAX5821M_MAX_DATA_VALUE 1024
+#define MAX5821M_MAX_DATA_VALUE 1023
/* transfered data structs */
typedef struct
@@ -85,8 +85,8 @@ typedef struct
#define BUILD_DATA_COMMAND(InSruct, Buf) \
{ \
- Buf[0] = (InSruct.command << 4) + (unsigned char) (InSruct.data>>6);\
- Buf[1] = (unsigned char) (InSruct.data<<2);\
+ Buf[0] = (InSruct.command << 4) + (unsigned char) (InSruct.data >> 6);\
+ Buf[1] = (unsigned char) (InSruct.data << 2);\
}
#define BUILD_EXTENDED_COMMAND(InSruct, Buf) \
diff --git a/target/packages/max5821ctrl/setDAC.c b/target/packages/max5821ctrl/setDAC.c
index c96f5de..d1cd50d 100644
--- a/target/packages/max5821ctrl/setDAC.c
+++ b/target/packages/max5821ctrl/setDAC.c
@@ -1,7 +1,7 @@
/*
** THE ARMADEUS PROJECT
**
-** Copyright (C) year The source forge armadeus project team
+** Copyright (C) 2008 The source forge armadeus project team
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,6 @@
** author: ca...@us...
*/
-
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
@@ -34,7 +33,13 @@
#include <sys/ioctl.h>
#include "max5821.h"
-// #define DEBUG_MAX5821 1
+/*#define DEBUG_MAX5821 1 */
+
+#ifdef DEBUG_MAX5821
+# define DEBUG(fmt, ...) printf(fmt, ##__VA_ARGS__)
+#else
+# define DEBUG(fmt, ...) do { ; } while (0)
+#endif
void usage()
@@ -51,96 +56,73 @@ int main(int argc, char *argv[])
{
int bus;
int value;
- extended_command powerDownCommand = {0, 0, 0, 0};
- extended_command powerUpCommand = {0, 0, 0, 0};
- data_command setDACOutput = {0, 0, 0};
+ extended_command powerCommand = {0, 0, 0, 0};
+ data_command setOutputCommand = {0, 0, 0};
unsigned char buf[2];
- if ((argc != 2) && (argc != 3))
- {
+ if ((argc != 2) && (argc != 3)) {
usage();
}
- if ((bus = open("/dev/i2c-0", O_RDWR)) < 0)
- {
- perror("Open error: ");
+ if ((bus = open("/dev/i2c-0", O_RDWR)) < 0) {
+ perror("Open error");
exit(1);
}
- if (ioctl(bus,/*I2C_SLAVE*/ 0x703, MAX5821L_IC_SLAVE_ADDRESS_GND) < 0)
- {
- perror("Ioctl error: ");
+ if (ioctl(bus, I2C_SLAVE, MAX5821L_IC_SLAVE_ADDRESS_GND) < 0) {
+ perror("Ioctl error");
exit(1);
}
- powerDownCommand.command = MAX5821_EXTENDED_COMMAND_MODE;
- powerDownCommand.powerMode = POWER_DOWN_MODE0;
- powerUpCommand.command = MAX5821_EXTENDED_COMMAND_MODE;
- powerUpCommand.powerMode = POWER_UP;
+ powerCommand.command = MAX5821_EXTENDED_COMMAND_MODE;
- setDACOutput.Sbits = 0;
- if (0 == strcmp(argv[1],"A"))
- {
- powerDownCommand.ctrlA = POWER_CTRL_SELECTED;
- powerDownCommand.ctrlB = POWER_CTRL_UNSELECTED;
- powerUpCommand.ctrlA = POWER_CTRL_SELECTED;
- powerUpCommand.ctrlB = POWER_CTRL_UNSELECTED;
- setDACOutput.command = MAX5821_LOAD_DAC_A_IN_REG_B;
+ setOutputCommand.Sbits = 0;
+ if (0 == strcmp(argv[1], "A")) {
+ powerCommand.ctrlA = POWER_CTRL_SELECTED;
+ powerCommand.ctrlB = POWER_CTRL_UNSELECTED;
+ setOutputCommand.command = MAX5821_LOAD_DAC_A_IN_REG_B;
}
- else if (0 == strcmp(argv[1],"B"))
- {
- powerDownCommand.ctrlA = POWER_CTRL_UNSELECTED;
- powerDownCommand.ctrlB = POWER_CTRL_SELECTED;
- powerUpCommand.ctrlA = POWER_CTRL_UNSELECTED;
- powerUpCommand.ctrlB = POWER_CTRL_SELECTED;
- setDACOutput.command = MAX5821_LOAD_DAC_B_IN_REG_A;
+ else if (0 == strcmp(argv[1], "B")) {
+ powerCommand.ctrlA = POWER_CTRL_UNSELECTED;
+ powerCommand.ctrlB = POWER_CTRL_SELECTED;
+ setOutputCommand.command = MAX5821_LOAD_DAC_B_IN_REG_A;
}
- else if (0 == strcmp(argv[1],"AB"))
- {
- powerDownCommand.ctrlA = POWER_CTRL_SELECTED;
- powerDownCommand.ctrlB = POWER_CTRL_SELECTED;
- powerUpCommand.ctrlA = POWER_CTRL_SELECTED;
- powerUpCommand.ctrlB = POWER_CTRL_SELECTED;
- setDACOutput.command = MAX5821_LOAD_DAC_ALL_IN_UPDATE_ALL;
- }
- else
- {
+ else if (0 == strcmp(argv[1], "AB")) {
+ powerCommand.ctrlA = POWER_CTRL_SELECTED;
+ powerCommand.ctrlB = POWER_CTRL_SELECTED;
+ setOutputCommand.command = MAX5821_LOAD_DAC_ALL_IN_UPDATE_ALL;
+ } else {
usage();
}
- if (argc == 2)
- {
- BUILD_EXTENDED_COMMAND(powerDownCommand, buf);
-#ifdef DEBUG_MAX5821
- printf("Set the DAC : %02X %02X \n", buf[0], buf[1]);
-#endif
- }
- else
- {
+ if (argc == 2) {
+ /* No value given -> power down channel */
+ powerCommand.powerMode = POWER_DOWN_MODE0;
+ BUILD_EXTENDED_COMMAND(powerCommand, buf);
+ DEBUG("Set the DAC: %02X %02X \n", buf[0], buf[1]);
+ } else {
value = atoi(argv[2]);
- if (value >= MAX5821M_MAX_DATA_VALUE)
+ if (value > MAX5821M_MAX_DATA_VALUE)
usage();
- /* first, we power up the DAC */
- BUILD_EXTENDED_COMMAND(powerUpCommand, buf);
-#ifdef DEBUG_MAX5821
- printf("Set the DAC : %02X %02X \n", buf[0], buf[1]);
-#endif
- if (0 > write(bus, buf, 2))
- {
- printf("Write error\n");
+ /* First, we power up the channel(s) */
+ powerCommand.powerMode = POWER_UP;
+ BUILD_EXTENDED_COMMAND(powerCommand, buf);
+ DEBUG("Set the DAC: %02X %02X \n", buf[0], buf[1]);
+ if (0 > write(bus, buf, 2)) {
+ perror("Write error");
exit(1);
}
- setDACOutput.data = value;
- BUILD_DATA_COMMAND(setDACOutput, buf);
-#ifdef DEBUG_MAX5821
- printf("Set the DAC : %02X %02X \n", buf[0], buf[1]);
-#endif
+ /* Then we prepare the command to set channel value */
+ setOutputCommand.data = value;
+ BUILD_DATA_COMMAND(setOutputCommand, buf);
+ DEBUG("Set the DAC: %02X %02X \n", buf[0], buf[1]);
}
- if (0 > write(bus, buf, 2))
- {
- printf("Write error\n");
+ /* Send previously built command */
+ if (0 > write(bus, buf, 2)) {
+ perror("Write error");
exit(1);
}
exit(0);
}
+
hooks/post-receive
--
armadeus
|