slight cleanup

This commit is contained in:
Conor Patrick 2019-05-09 14:53:22 -04:00
parent 30cfa46186
commit 4ac61f7f18
2 changed files with 3 additions and 8 deletions

View File

@ -30,11 +30,7 @@ void tsc_init()
PA6 ------> sampling cap PA6 ------> sampling cap
*/ */
GPIO_InitStruct.Pin = LL_GPIO_PIN_6; GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_9;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct); LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
// Channel IOs // Channel IOs
@ -44,7 +40,7 @@ void tsc_init()
TSC->CR = TSC_CR_TSCE; TSC->CR = TSC_CR_TSCE;
TSC->CR |= (TSC_CTPH_8CYCLES | TSC->CR |= (TSC_CTPH_8CYCLES |
TSC_CTPL_8CYCLES | TSC_CTPL_10CYCLES |
(uint32_t)(1 << TSC_CR_SSD_Pos) | (uint32_t)(1 << TSC_CR_SSD_Pos) |
TSC_SS_PRESC_DIV1 | TSC_SS_PRESC_DIV1 |
TSC_PG_PRESC_DIV16 | TSC_PG_PRESC_DIV16 |
@ -105,8 +101,6 @@ uint32_t tsc_read(uint32_t indx)
return TSC->IOGXCR[indx]; return TSC->IOGXCR[indx];
} }
// Read button 0 or 1
// Returns 1 if pressed, 0 if not.
uint32_t tsc_read_button(uint32_t index) uint32_t tsc_read_button(uint32_t index)
{ {
switch(index) switch(index)
@ -117,7 +111,6 @@ uint32_t tsc_read_button(uint32_t index)
case 1: case 1:
tsc_set_electrode(ELECTRODE_1); tsc_set_electrode(ELECTRODE_1);
break; break;
} }
tsc_start_acq(); tsc_start_acq();
tsc_wait_on_acq(); tsc_wait_on_acq();

View File

@ -7,6 +7,8 @@ void tsc_init();
int tsc_sensor_exists(); int tsc_sensor_exists();
// Read button0 or button1
// Returns 1 if pressed, 0 if not.
uint32_t tsc_read_button(uint32_t index); uint32_t tsc_read_button(uint32_t index);
#endif #endif