mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-04 15:08:39 -04:00
AP_HAL_Linux: RCInput_RPI: fix coding style
- Remove trailing whitespaces - Remove some uneeded comments - Fix indentation - Replace some breaks inside the loop by checking in the loop itself
This commit is contained in:
parent
79d56073f7
commit
51fd0b3d55
@ -52,7 +52,7 @@ static uint16_t RcChnGpioTbl[RCIN_RPI_CHN_NUM] = {
|
||||
static uint16_t RcChnGpioTbl[RCIN_RPI_CHN_NUM] = {
|
||||
RPI_GPIO_4
|
||||
};
|
||||
#endif // CONFIG_HAL_BOARD_SUBTYPE
|
||||
#endif
|
||||
|
||||
//Memory Addresses
|
||||
#define RCIN_RPI_RPI1_DMA_BASE 0x20007000
|
||||
@ -162,7 +162,8 @@ Memory_table::~Memory_table()
|
||||
free(_phys_pages);
|
||||
}
|
||||
|
||||
// This function returns physical address with help of pointer, which is offset from the beginning of the buffer.
|
||||
/* Return physical address with help of pointer, which is offset from the
|
||||
* beginning of the buffer. */
|
||||
void* Memory_table::get_page(void** const pages, uint32_t addr) const
|
||||
{
|
||||
if (addr >= PAGE_SIZE * _page_count) {
|
||||
@ -174,8 +175,6 @@ void* Memory_table::get_page(void** const pages, uint32_t addr) const
|
||||
// Get virtual address from the corresponding physical address from memory_table.
|
||||
void *Memory_table::get_virt_addr(const uint32_t phys_addr) const
|
||||
{
|
||||
// FIXME: Can't the address be calculated directly?
|
||||
// FIXME: if the address room in _phys_pages is not fragmented one may avoid a complete loop ..
|
||||
uint32_t i = 0;
|
||||
for (; i < _page_count; i++) {
|
||||
if ((uintptr_t) _phys_pages[i] == (((uintptr_t) phys_addr) & 0xFFFFF000)) {
|
||||
@ -185,8 +184,7 @@ void* Memory_table::get_virt_addr(const uint32_t phys_addr) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FIXME: in-congruent function style see above
|
||||
// This function returns offset from the beginning of the buffer using virtual address and memory_table.
|
||||
// Return offset from the beginning of the buffer using virtual address and memory_table.
|
||||
uint32_t Memory_table::get_offset(void ** const pages, const uint32_t addr) const
|
||||
{
|
||||
uint32_t i = 0;
|
||||
@ -203,8 +201,7 @@ uint32_t Memory_table::bytes_available(const uint32_t read_addr, const uint32_t
|
||||
{
|
||||
if (write_addr > read_addr) {
|
||||
return (write_addr - read_addr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return _page_count * PAGE_SIZE - (read_addr - write_addr);
|
||||
}
|
||||
}
|
||||
@ -221,8 +218,7 @@ void RCInput_RPI::set_physical_addresses(int version)
|
||||
dma_base = RCIN_RPI_RPI1_DMA_BASE;
|
||||
clk_base = RCIN_RPI_RPI1_CLK_BASE;
|
||||
pcm_base = RCIN_RPI_RPI1_PCM_BASE;
|
||||
}
|
||||
else if (version == 2) {
|
||||
} else if (version == 2) {
|
||||
dma_base = RCIN_RPI_RPI2_DMA_BASE;
|
||||
clk_base = RCIN_RPI_RPI2_CLK_BASE;
|
||||
pcm_base = RCIN_RPI_RPI2_PCM_BASE;
|
||||
@ -299,8 +295,7 @@ void RCInput_RPI::init_ctrl_data()
|
||||
// fprintf(stderr, "ERROR SEARCH1\n");
|
||||
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < 7 * 128 * RCIN_RPI_BUFFER_LENGTH; i++) // 7 * 128 * 8 == 7168
|
||||
{
|
||||
for (i = 0; i < 7 * 128 * RCIN_RPI_BUFFER_LENGTH; i++) {
|
||||
//Transfer timer every 7th sample
|
||||
if (i % 7 == 0) {
|
||||
cbp_curr = (dma_cb_t*)con_blocks->get_page(con_blocks->_virt_pages, cbp);
|
||||
@ -442,7 +437,7 @@ void RCInput_RPI::init_registers()
|
||||
|
||||
void RCInput_RPI::init()
|
||||
{
|
||||
uint64_t signal_states(0);
|
||||
uint64_t signal_states = 0;
|
||||
|
||||
init_registers();
|
||||
|
||||
@ -486,10 +481,8 @@ void RCInput_RPI::_timer_tick()
|
||||
|
||||
//Now we are getting address in which DMAC is writing at current moment
|
||||
dma_cb_t* ad = (dma_cb_t*) con_blocks->get_virt_addr(dma_reg[RCIN_RPI_DMA_CONBLK_AD | RCIN_RPI_DMA_CHANNEL << 8]);
|
||||
for(j = 1; j >= -1; j--){
|
||||
for (j = 1; j >= -1 && x == nullptr; j--) {
|
||||
x = circle_buffer->get_virt_addr((ad + j)->dst);
|
||||
if(x != NULL) {
|
||||
break;}
|
||||
}
|
||||
|
||||
//How many bytes have DMA transfered (and we can process)?
|
||||
@ -525,11 +518,8 @@ void RCInput_RPI::_timer_tick()
|
||||
if (rc_channels[i].curr_signal == 0) {
|
||||
rc_channels[i].width_s0 = (uint16_t)rc_channels[i].delta_time;
|
||||
rc_channels[i].state = RCIN_RPI_ONE_STATE;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
case RCIN_RPI_ONE_STATE:
|
||||
if (rc_channels[i].curr_signal == 1) {
|
||||
rc_channels[i].width_s1 = (uint16_t)rc_channels[i].delta_time;
|
||||
@ -540,14 +530,11 @@ void RCInput_RPI::_timer_tick()
|
||||
#else
|
||||
_process_rc_pulse(rc_channels[i].width_s0,
|
||||
rc_channels[i].width_s1);
|
||||
#endif // CONFIG_HAL_BOARD_SUBTYPE
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
rc_channels[i].last_signal = rc_channels[i].curr_signal;
|
||||
}
|
||||
curr_pointer += 8;
|
||||
@ -558,4 +545,4 @@ void RCInput_RPI::_timer_tick()
|
||||
curr_tick += curr_tick_inc;
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_HAL_BOARD_SUBTYPE
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user