From 26cd4ad23708f01dda38c98a53e8a6686de844da Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Tue, 13 May 2014 16:51:07 +0530 Subject: [PATCH] HAL_Linux: Correct indentation --- libraries/AP_HAL_Linux/RCOutput.cpp | 202 ++++++++++++++-------------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/libraries/AP_HAL_Linux/RCOutput.cpp b/libraries/AP_HAL_Linux/RCOutput.cpp index b30297ca3e..a75228f05d 100644 --- a/libraries/AP_HAL_Linux/RCOutput.cpp +++ b/libraries/AP_HAL_Linux/RCOutput.cpp @@ -11,97 +11,97 @@ using namespace std; #define PWM_DIR_EXPORT "/sys/class/pwm/export" #define PWM_CHAN_COUNT 12 -int chan_pru_map[]= {10,8,11,9,7,6,5,4,3,2,1,0}; //chan_pru_map[CHANNEL_NUM] = PRU_REG_R30/31_NUM; -int pru_chan_map[]= {11,10,9,8,7,6,5,4,1,3,0,2}; //pru_chan_map[PRU_REG_R30/31_NUM] = CHANNEL_NUM; +int chan_pru_map[]= {10,8,11,9,7,6,5,4,3,2,1,0}; //chan_pru_map[CHANNEL_NUM] = PRU_REG_R30/31_NUM; +int pru_chan_map[]= {11,10,9,8,7,6,5,4,1,3,0,2}; //pru_chan_map[PRU_REG_R30/31_NUM] = CHANNEL_NUM; void LinuxRCOutput::init() { - DIR* _pwm_dir = opendir(PWM_DIR); - int _pwm_fd; - char chan[2]; + DIR* _pwm_dir = opendir(PWM_DIR); + int _pwm_fd; + char chan[2]; struct dirent *dir; - int pru_load_success=0; - int exported_count=0; - int i,pru_r30; + int pru_load_success=0; + int exported_count=0; + int i,pru_r30; if (_pwm_dir){ - while ((dir = readdir(_pwm_dir)) != NULL){ - if(strcmp(dir->d_name,"pwmchip0")==0){ - pru_load_success = 1; - closedir(_pwm_dir); - break; + while ((dir = readdir(_pwm_dir)) != NULL){ + if(strcmp(dir->d_name,"pwmchip0")==0){ + pru_load_success = 1; + closedir(_pwm_dir); + break; } } - if(!pru_load_success){ - perror("PRU PWM LOAD failed: PRU might not be enabled"); - } + if(!pru_load_success){ + perror("PRU PWM LOAD failed: PRU might not be enabled"); + } - } + } else{ perror("PWM DIR not found"); } - - _pwm_fd = open(PWM_DIR_EXPORT,O_WRONLY); + + _pwm_fd = open(PWM_DIR_EXPORT,O_WRONLY); if(_pwm_fd < 0){ - perror("PWM_EXPORT not found"); - } + perror("PWM_EXPORT not found"); + } - for(i=0;id_name+3,NULL,10); - if(pru_r30>0 && pru_r30<12){ - write1(pru_chan_map[pru_r30],10); //writing absolute minimum to duty_ns necessary for pwm_sysfs to start working - //printf("CHANNEL %d",pru_chan_map[pru_r30]); - //printf(" exported\n"); - exported_count++; - } - else if(strcmp(dir->d_name,"pwm0")==0){ - write1(pru_chan_map[pru_r30],10); - //printf("CHANNEL %d",pru_chan_map[0]); - //printf(" exported \n"); - exported_count++; - } - } - if(exported_count != PWM_CHAN_COUNT){ - printf("WARNING: All channels not exported\n"); - } + while ((dir = readdir(_pwm_dir)) != NULL){ + pru_r30=strtol(dir->d_name+3,NULL,10); + if(pru_r30>0 && pru_r30<12){ + write1(pru_chan_map[pru_r30],10); //writing absolute minimum to duty_ns necessary for pwm_sysfs to start working + //printf("CHANNEL %d",pru_chan_map[pru_r30]); + //printf(" exported\n"); + exported_count++; + } + else if(strcmp(dir->d_name,"pwm0")==0){ + write1(pru_chan_map[pru_r30],10); + //printf("CHANNEL %d",pru_chan_map[0]); + //printf(" exported \n"); + exported_count++; + } + } + if(exported_count != PWM_CHAN_COUNT){ + printf("WARNING: All channels not exported\n"); + } closedir(_pwm_dir); } -void LinuxRCOutput::set_freq(uint32_t chmask, uint32_t freq_hz) //LSB corresponds to CHAN_1 +void LinuxRCOutput::set_freq(uint32_t chmask, uint32_t freq_hz) //LSB corresponds to CHAN_1 { - int _fd, ret,i; + int _fd, ret,i; unsigned long period_ns=1000000000/freq_hz; - char period_sysfs_path[20],buffer[15]; + char period_sysfs_path[20],buffer[15]; sprintf(buffer,"%lu",(unsigned long)period_ns); - for(i=0;i<12;i++){ - if(chmask&(1<