(minor) remove trailing spaces

This commit is contained in:
King Kévin 2019-03-26 19:27:40 +01:00
parent b4612b03bb
commit 230151a102
24 changed files with 170 additions and 171 deletions

View File

@ -73,7 +73,7 @@ size_t putc(char c)
usb_cdcacm_putchar(c); // send byte over USB
length++; // remember we printed 1 character
last_c = c; // remember last character
return length; // return number of characters printed
return length; // return number of characters printed
}
/** display available commands

View File

@ -110,7 +110,7 @@ void sleep_us(uint32_t duration)
sleep_duration = duration; // save sleep duration for count down
systick_counter_enable(); // start counting
while (sleep_duration>0) { // wait for count down to complete
__WFI(); // go to sleep
__WFI(); // go to sleep
}
}
@ -125,7 +125,7 @@ void sleep_ms(uint32_t duration)
sleep_duration = duration; // save sleep duration for count down
systick_counter_enable(); // start counting
while (sleep_duration>0) { // wait for count down to complete
__WFI(); // go to sleep
__WFI(); // go to sleep
}
}

View File

@ -249,7 +249,7 @@ static uint8_t flash_sdcard_write_block(uint8_t* data, size_t size)
spi_disable_crc(SPI(FLASH_SDCARD_SPI)); // disable CRC since we don't use it anymore (and this allows us to clear the CRC next time we use it)
spi_set_dff_8bit(SPI(FLASH_SDCARD_SPI)); // set SPI frame to 8 bits
spi_enable(SPI(FLASH_SDCARD_SPI)); // enable SPI back
uint8_t token = 0xff;
while (0x01!=(token&0x11)) {
token = flash_sdcard_spi_read(); // get data response token (see section 7.3.3.1)
@ -511,7 +511,7 @@ bool flash_sdcard_setup(void)
}
erase_size = (8192UL<<(status[10]>>4)); // calculate erase size (see table 4-44, section 4.10.2.4)
}
// ensure block length is 512 bytes for SDSC (should be per default) to we match SDHC/SDXC block size
if (sdsc) {
r1 = flash_sdcard_command_response(16, 512, NULL, 0); // set block size using CMD16 (SET_BLOCKLEN) (see table 7-3)

View File

@ -461,7 +461,7 @@ enum i2c_master_rc i2c_master_write(uint32_t i2c, const uint8_t* data, size_t da
// sanity check
if (NULL == data || 0 == data_size) { // no data to write
return I2C_MASTER_RC_NONE;
}
}
if (!(I2C_SR2(i2c) & I2C_SR2_MSL)) { // I2C device is not master
return I2C_MASTER_RC_NOT_MASTER;
}

View File

@ -60,99 +60,99 @@
*/
static const uint8_t ascii_7segments[] = {
0x00, // space
0x06, // ! (I)
0x22, // "
0x1d, // # (o)
0x5b, // $ (s)
0x25, // % (/)
0x5f, // & (6)
0x02, // '
0x4e, // ( ([)
0x78, // )
0x07, // *
0x31, // +
0x04, // ,
0x01, // -
0x04, // . (,)
0x25, // /
0x7e, // 0
0x30, // 1
0x6d, // 2
0x79, // 3
0x33, // 4
0x5b, // 5
0x5f, // 6
0x70, // 7
0x7f, // 8
0x7b, // 9
0x09, // : (=)
0x09, // ; (=)
0x0d, // <
0x09, // =
0x19, // >
0x65, // ?
0x6f, // @
0x77, // A
0x7f, // B
0x4e, // C
0x3d, // D
0x4f, // E
0x47, // F
0x5e, // G
0x37, // H
0x06, // I
0x3c, // J
0x37, // K
0x0e, // L
0x76, // M
0x76, // N
0x7e, // O
0x67, // P
0x6b, // Q
0x66, // R
0x5b, // S
0x0f, // T
0x3e, // U
0x3e, // V (U)
0x3e, // W (U)
0x37, // X (H)
0x3b, // Y
0x6d, // Z
0x4e, // [
0x13, // '\'
0x78, // /
0x62, // ^
0x08, // _
0x20, // `
0x7d, // a
0x1f, // b
0x0d, // c
0x3d, // d
0x6f, // e
0x47, // f
0x7b, // g
0x17, // h
0x04, // i
0x18, // j
0x37, // k
0x06, // l
0x15, // m
0x15, // n
0x1d, // o
0x67, // p
0x73, // q
0x05, // r
0x5b, // s
0x0f, // t
0x1c, // u
0x1c, // v (u)
0x1c, // w (u)
0x37, // x
0x3b, // y
0x6d, // z
0x4e, // { ([)
0x06, // |
0x78, // } ([)
0x06, // ! (I)
0x22, // "
0x1d, // # (o)
0x5b, // $ (s)
0x25, // % (/)
0x5f, // & (6)
0x02, // '
0x4e, // ( ([)
0x78, // )
0x07, // *
0x31, // +
0x04, // ,
0x01, // -
0x04, // . (,)
0x25, // /
0x7e, // 0
0x30, // 1
0x6d, // 2
0x79, // 3
0x33, // 4
0x5b, // 5
0x5f, // 6
0x70, // 7
0x7f, // 8
0x7b, // 9
0x09, // : (=)
0x09, // ; (=)
0x0d, // <
0x09, // =
0x19, // >
0x65, // ?
0x6f, // @
0x77, // A
0x7f, // B
0x4e, // C
0x3d, // D
0x4f, // E
0x47, // F
0x5e, // G
0x37, // H
0x06, // I
0x3c, // J
0x37, // K
0x0e, // L
0x76, // M
0x76, // N
0x7e, // O
0x67, // P
0x6b, // Q
0x66, // R
0x5b, // S
0x0f, // T
0x3e, // U
0x3e, // V (U)
0x3e, // W (U)
0x37, // X (H)
0x3b, // Y
0x6d, // Z
0x4e, // [
0x13, // '\'
0x78, // /
0x62, // ^
0x08, // _
0x20, // `
0x7d, // a
0x1f, // b
0x0d, // c
0x3d, // d
0x6f, // e
0x47, // f
0x7b, // g
0x17, // h
0x04, // i
0x18, // j
0x37, // k
0x06, // l
0x15, // m
0x15, // n
0x1d, // o
0x67, // p
0x73, // q
0x05, // r
0x5b, // s
0x0f, // t
0x1c, // u
0x1c, // v (u)
0x1c, // w (u)
0x37, // x
0x3b, // y
0x6d, // z
0x4e, // { ([)
0x06, // |
0x78, // } ([)
0x01, // ~
};

View File

@ -289,7 +289,7 @@ bool led_tm1637_number(uint16_t number)
{
uint8_t write_data[] = { 0x40 }; // command: write data, automatic address adding, normal
uint8_t data[] = { 0xc0, ascii_7segments[((number/1000)%10)+'0'-' '], ascii_7segments[((number/100)%10)+'0'-' '], ascii_7segments[((number/10)%10)+'0'-' '], ascii_7segments[((number/1)%10)+'0'-' '] }; // set address C0H and add data
if (led_tm1637_write(write_data,LENGTH(write_data)) && led_tm1637_write(data,LENGTH(data))) { // send commands
return true;
}
@ -300,7 +300,7 @@ bool led_tm1637_time(uint8_t hours, uint8_t minutes)
{
uint8_t write_data[] = { 0x40 }; // command: write data, automatic address adding, normal
uint8_t data[] = { 0xc0, ascii_7segments[((hours/10)%10)+'0'-' '], ascii_7segments[((hours/1)%10)+'0'-' ']|0x80, ascii_7segments[((minutes/10)%10)+'0'-' '], ascii_7segments[((minutes/1)%10)+'0'-' '] }; // set address C0H and add data
if (led_tm1637_write(write_data,LENGTH(write_data)) && led_tm1637_write(data,LENGTH(data))) { // send commands
return true;
}
@ -319,7 +319,7 @@ bool led_tm1637_text(char* text)
}
uint8_t write_data[] = { 0x40 }; // command: write data, automatic address adding, normal
uint8_t data[] = { 0xc0, ascii_7segments[(text[0]&0x7f)-' ']|(text[0]&0x80), ascii_7segments[(text[1]&0x7f)-' ']|(text[1]&0x80), ascii_7segments[(text[2]&0x7f)-' ']|(text[2]&0x80), ascii_7segments[(text[3]&0x7f)-' ']|(text[3]&0x80) }; // set address C0H and add data
if (led_tm1637_write(write_data,LENGTH(write_data)) && led_tm1637_write(data,LENGTH(data))) { // send commands
return true;
}

View File

@ -138,9 +138,9 @@ void led_ws2812b_setup(void)
spi_send_msb_first(SPI(LED_WS2812B_SPI)); // send least significant bit first
spi_enable_software_slave_management(SPI(LED_WS2812B_SPI)); // control the slave select in software (since there is no master)
spi_set_nss_low(SPI(LED_WS2812B_SPI)); // set NSS low so we can output
spi_enable(SPI(LED_WS2812B_SPI)); // enable SPI
spi_enable(SPI(LED_WS2812B_SPI)); // enable SPI
// do not disable SPI or set NSS high since it will put MISO high, breaking the beginning of the next transmission
// configure DMA to provide the pattern to be shifted out from SPI to the WS2812B LEDs
rcc_periph_clock_enable(RCC_DMA_SPI(LED_WS2812B_SPI)); // enable clock for DMA peripheral
dma_channel_reset(DMA_SPI(LED_WS2812B_SPI), DMA_CHANNEL_SPI_TX(LED_WS2812B_SPI)); // start with fresh channel configuration
@ -177,5 +177,5 @@ void DMA_ISR_SPI_TX(LED_WS2812B_SPI)(void)
timer_disable_counter(TIM(LED_WS2812B_TIMER)); // stop clock
dma_disable_channel(DMA_SPI(LED_WS2812B_SPI), DMA_CHANNEL_SPI_TX(LED_WS2812B_SPI)); // stop using DMA
transmit_flag = false; // transmission completed
}
}
}

View File

@ -97,7 +97,6 @@ static void microwire_master_wait_clock(void)
}
timer_clear_flag(TIM(MICROWIRE_MASTER_TIMER), TIM_SR_UIF); // clear timer flag
nvic_clear_pending_irq(NVIC_TIM_IRQ(MICROWIRE_MASTER_TIMER)); // clear IRQ flag (else event doesn't wake up)
}
/** send bit over microwire
@ -194,7 +193,7 @@ void microwire_master_read(uint32_t address, uint16_t* data, size_t length)
// there should already be a '0' dummy bit
if (0!=gpio_get(GPIO(MICROWIRE_MASTER_SDI_PORT), GPIO(MICROWIRE_MASTER_SDI_PIN))) { // the dummy bit wasn't '0'
goto clean;
goto clean;
}
// read data
@ -207,7 +206,7 @@ void microwire_master_read(uint32_t address, uint16_t* data, size_t length)
}
}
}
clean:
microwire_master_stop(); // stop communication and clean up
}
@ -251,7 +250,7 @@ void microwire_master_write(uint32_t address, uint16_t data)
microwire_master_send_bit(false); // send '0' data bit
}
}
microwire_master_stop(); // clean up
}
@ -310,6 +309,6 @@ void microwire_master_write_all(uint16_t data)
microwire_master_send_bit(false); // send '0' data bit
}
}
microwire_master_stop(); // clean up
}

View File

@ -57,7 +57,7 @@ volatile enum {
ONEWIRE_STATE_MASTER_RESET, /**< reset pulse started */
ONEWIRE_STATE_SLAVE_PRESENCE, /**< waiting for slave response to reset pulse */
ONEWIRE_STATE_MASTER_WRITE, /**< master is writing bits */
ONEWIRE_STATE_MASTER_READ, /**< master is reading bits */
ONEWIRE_STATE_MASTER_READ, /**< master is reading bits */
ONEWIRE_MAX /** to count the number of possible states */
} onewire_master_state = ONEWIRE_STATE_IDLE;
@ -116,7 +116,7 @@ void TIM_ISR(ONEWIRE_MASTER_TIMER)(void)
timer_clear_flag(TIM(ONEWIRE_MASTER_TIMER), TIM_SR_CC1IF); // clear flag
switch (onewire_master_state) {
case ONEWIRE_STATE_MASTER_READ: // master has to read a bit
gpio_set(GPIO(ONEWIRE_MASTER_PORT),GPIO(ONEWIRE_MASTER_PIN)); // pull signal high to end time slot
gpio_set(GPIO(ONEWIRE_MASTER_PORT),GPIO(ONEWIRE_MASTER_PIN)); // pull signal high to end time slot
break;
default: // unknown state for this stage
break; // let the overflow handle the error if any
@ -135,7 +135,7 @@ void TIM_ISR(ONEWIRE_MASTER_TIMER)(void)
onewire_master_state = ONEWIRE_STATE_ERROR; // indicate error
}
break;
case ONEWIRE_STATE_MASTER_READ: // master has to read a bit set by slave
case ONEWIRE_STATE_MASTER_READ: // master has to read a bit set by slave
if (buffer_bit<buffer_size) { // check if byte to send are remaining
if (gpio_get(GPIO(ONEWIRE_MASTER_PORT),GPIO(ONEWIRE_MASTER_PIN))) { // check if the slave kept it low
buffer[buffer_bit/8] |= (1<<(buffer_bit%8)); // save bit "1"
@ -172,7 +172,7 @@ void onewire_master_setup(void)
rcc_periph_clock_enable(RCC_GPIO(ONEWIRE_MASTER_PORT)); // enable clock for GPIO peripheral
gpio_set(GPIO(ONEWIRE_MASTER_PORT),GPIO(ONEWIRE_MASTER_PIN)); // idle is high (using pull-up resistor)
gpio_set_mode(GPIO(ONEWIRE_MASTER_PORT), GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO(ONEWIRE_MASTER_PIN)); // normal 1-Wire communication (only using external pull-up resistor)
// setup timer to generate/measure signal timing
rcc_periph_clock_enable(RCC_TIM(ONEWIRE_MASTER_TIMER)); // enable clock for timer peripheral
timer_reset(TIM(ONEWIRE_MASTER_TIMER)); // reset timer state
@ -413,13 +413,13 @@ uint64_t onewire_master_rom_read(void)
if (onewire_master_crc(rom_code, LENGTH(rom_code))) { // verify checksum
return 0; // checksum is wrong (not 0)
}
// return ROM code
uint64_t code = 0;
for (uint32_t i=0; i<8; i++) {
code += (uint64_t)rom_code[i]<<(8*i); // add byte
}
return code;
}

View File

@ -72,13 +72,13 @@ bool onewire_master_rom_skip(void);
*/
bool onewire_master_rom_match(uint64_t code);
/** read data byte
* @note it is up to the user to send the reset pulse
* @note it is up to the user to send the reset pulse
* @param[out] data buffer to save data read
* @return if operation succeeded
*/
bool onewire_master_read_byte(uint8_t* data);
/** write data byte
* @note it is up to the user to send the reset pulse
* @note it is up to the user to send the reset pulse
* @param[in] data byte to write
* @return if operation succeeded
*/

View File

@ -94,7 +94,7 @@ static uint8_t onewire_slave_crc(uint8_t* data, uint32_t length)
if (NULL==data || 0==length) { // check input
return 0; // wrong input
}
uint8_t crc = 0x00; // initial value
for (uint8_t i=0; i<length; i++) { // go through every byte
crc ^= data[i]; // XOR byte
@ -120,7 +120,7 @@ void onewire_slave_setup(uint8_t family, uint64_t serial)
onewire_slave_rom_code[5] = serial >> 8;
onewire_slave_rom_code[6] = serial >> 0;
onewire_slave_rom_code[7] = onewire_slave_crc(onewire_slave_rom_code, 7); // calculate CRC
// setup timer to generate/measure signal timing
rcc_periph_clock_enable(RCC_TIM(ONEWIRE_SLAVE_TIMER)); // enable clock for timer peripheral
timer_reset(TIM(ONEWIRE_SLAVE_TIMER)); // reset timer state
@ -344,7 +344,7 @@ void TIM_ISR(ONEWIRE_SLAVE_TIMER)(void)
onewire_slave_state = ONEWIRE_STATE_IDLE; // stop comparing and go back to idle
}
}
break;
break;
case ONEWIRE_STATE_ROM_SEARCH_TRUE: // ROM code bit is send, prepare to send negated version
bits_buffer ^= (1<<bits_bit); // negate bit
onewire_slave_state = ONEWIRE_STATE_ROM_SEARCH_FALSE; // send negated version
@ -367,7 +367,7 @@ void TIM_ISR(ONEWIRE_SLAVE_TIMER)(void)
bits_buffer = onewire_slave_rom_code[rom_code_byte]; // prepare next ROM code byte
}
}
break;
break;
case ONEWIRE_STATE_FUNCTION_COMMAND: // read function command
if (bits_bit>7) { // complete function command code received
onewire_slave_function_code = bits_buffer; // save function command code to user buffer

View File

@ -272,7 +272,7 @@ static size_t print_hex(char** str, size_t* size, uint64_t hex, uint32_t padding
print_printed(&length, print_nibble(str, size, hex>>((digits-digit-1)*4), upcase)); // print nibble (in reverse order)
}
return length; // return number of characters printed
}
}
/** print bits
* @param[out] str string to print bits on (use NULL to print on user output)
@ -311,7 +311,7 @@ static size_t print_bits(char** str, size_t* size, uint64_t u, uint32_t padding,
* @param[in,out] size size of string (writes at most size characters on str, including the termination null character '\0')
* @param[in] format format string to be printed
* @param[in] va arguments referenced by format string to be printed
* @return number of characters printed (a return value of size or more means that the output was truncated)
* @return number of characters printed (a return value of size or more means that the output was truncated)
**/
static size_t vsnprintf(char** str, size_t* size, const char *format, va_list va)
{
@ -338,7 +338,7 @@ static size_t vsnprintf(char** str, size_t* size, const char *format, va_list va
print_error |= PRINT_ERROR_MALFORMED; // set error
goto end;
}
}
}
// check padding
if ('0'==*format) { // padding required
padding = 0; // reset padding
@ -408,13 +408,13 @@ static size_t vsnprintf(char** str, size_t* size, const char *format, va_list va
case 'f':
print_printed(&length, print_float(str, size, va_arg(va,double), padding, fractional, sign));
break;
case 'x': // for uint8_t, uint16_t, uint32_t downcase hexadecimal
case 'x': // for uint8_t, uint16_t, uint32_t downcase hexadecimal
print_printed(&length, print_hex(str, size, va_arg(va,uint32_t), padding, sign, false));
break;
case 'X': // for uint64_t downcase hexadecimal
print_printed(&length, print_hex(str, size, va_arg(va,uint64_t), padding, sign, false));
break;
case 'h': // for uint8_t, uint16_t, uint32_t upcase hexadecimal
case 'h': // for uint8_t, uint16_t, uint32_t upcase hexadecimal
print_printed(&length, print_hex(str, size, va_arg(va,uint32_t), padding, sign, true));
break;
case 'H': // for uint64_t upcase hexadecimal

View File

@ -59,6 +59,6 @@ size_t printf(const char* format, ...);
* @param[in,out] size size of string (writes at most size characters on str, including the termination null character '\0')
* @param[in] format format string to be printed
* @param[in] ... arguments referenced by format string to be printed
* @return number of characters printed (a return value of size or more means that the output was truncated)
* @return number of characters printed (a return value of size or more means that the output was truncated)
**/
size_t snprintf(char* str, size_t size, const char* format, ...);

View File

@ -16,7 +16,7 @@
* @file rtc_dcf77.c
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016-2017
* @note peripherals used: GPIO @ref rtc_dcf77_gpio, timer @ref rtc_dcf77_timer
* @note peripherals used: GPIO @ref rtc_dcf77_gpio, timer @ref rtc_dcf77_timer
*/
/* standard libraries */

View File

@ -16,7 +16,7 @@
* @file rtc_dcf77.h
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016-2017
* @note peripherals used: GPIO @ref rtc_dcf77_gpio, timer @ref rtc_dcf77_timer
* @note peripherals used: GPIO @ref rtc_dcf77_gpio, timer @ref rtc_dcf77_timer
*/
#pragma once

View File

@ -179,7 +179,7 @@ bool sensor_ds18b20_precision(uint64_t code, uint8_t precision)
}
// send new configuration (and keep the alarm values)
uint8_t configuration[3] = {0}; // to store T_HIGH, T_LOW, and configuration
uint8_t configuration[3] = {0}; // to store T_HIGH, T_LOW, and configuration
configuration[0] = scratchpad[2]; // keep T_HIGH
configuration[1] = scratchpad[3]; // keep T_LOW
configuration[2] = 0x1f+((precision-9)<<5); // set precision bit (R1-R0 on bit 6-5)

View File

@ -16,7 +16,7 @@
* @file sensor_pzem.c
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016
* @note peripherals used: USART @ref sensor_pzem_usart, timer @ref sensor_pzem_timer
* @note peripherals used: USART @ref sensor_pzem_usart, timer @ref sensor_pzem_timer
*/
/* standard libraries */
@ -122,7 +122,7 @@ void sensor_pzem_measurement_request(uint32_t address, enum sensor_pzem_measurem
}
sensor_pzem_measurement_received = false; // reset flag
rx_i = 0; // prepare buffer to receive next measurement
rx_i = 0; // prepare buffer to receive next measurement
}
struct sensor_pzem_measurement_t sensor_pzem_measurement_decode(void)
@ -172,7 +172,7 @@ struct sensor_pzem_measurement_t sensor_pzem_measurement_decode(void)
rx_i = 0; // prepare buffer to receive next measurement
return measurement;
}
/** USART interrupt service routine called when data has been transmitted or received */
void USART_ISR(SENSOR_PZEM_USART)(void)
{

View File

@ -73,7 +73,7 @@ static enum timeout_t {
/** current timeout used */
static uint16_t timeout_times[TIMEOUT_MAX] = {0};
/** SDM120 3xxxx input register start addresses for the measurement types */
/** SDM120 3xxxx input register start addresses for the measurement types */
static const uint16_t register_input[] = {
0x0000, // 30001 voltage (in volts)
0x0006, // 30007 current (in amperes)
@ -223,7 +223,7 @@ static bool sensor_sdm120_transmit_request(uint8_t meter_id, uint8_t function, u
sensor_sdm120_measurement_received = false; // reset measurement flag
while (TIM_CR1(TIM(SENSOR_SDM120_TIMER))&TIM_CR1_CEN) { // timer is already used
__WFI(); // wait until something happens (timer is available again)
}
}
gpio_set(GPIO(SENSOR_SDM120_REDE_PORT),GPIO(SENSOR_SDM120_REDE_PIN)); // enable driver output and disable receive output
// start timeout
timeout = TIMEOUT_BEGIN; // select time before sending message
@ -298,7 +298,7 @@ float sensor_sdm120_measurement_decode(void)
rx_used = 0; // reset rx_buffer usage
return measurement;
}
/** USART interrupt service routine called when data has been transmitted or received */
void USART_ISR(SENSOR_SDM120_USART)(void)
{

View File

@ -99,7 +99,7 @@ static void terminal_shift_line(uint16_t to_copy, uint16_t nb_copy, uint16_t to_
terminal_shift_line(to_copy+1, nb_copy>0 ? nb_copy-1 : 0, to_shift+1); // shift next character
}
if (nb_copy>0) {
terminal_buffer[terminal_end-nb_copy] = c; // place back
terminal_buffer[terminal_end-nb_copy] = c; // place back
}
}
@ -359,7 +359,7 @@ void terminal_send(volatile char c)
}
terminal_line = terminal_line_new; // set new line start
terminal_last = true; // remember we are on the last line
}
}
if (terminal_line==terminal_end) { // line is empty
// nothing to do
} else {

View File

@ -140,7 +140,7 @@ bool uart_soft_setup(uint32_t *rx_baudrates, uint32_t *tx_baudrates)
gpio_set_mode(uart_soft_rx_states[rx]->port, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, uart_soft_rx_states[rx]->pin); // setup GPIO pin UART receive
gpio_set(uart_soft_rx_states[rx]->port, uart_soft_rx_states[rx]->pin); // pull up to avoid noise when not connected
rcc_periph_clock_enable(RCC_AFIO); // enable alternate function clock for external interrupt
exti_select_source(uart_soft_rx_states[rx]->exti, uart_soft_rx_states[rx]->port); // mask external interrupt of this pin only for this port
exti_select_source(uart_soft_rx_states[rx]->exti, uart_soft_rx_states[rx]->port); // mask external interrupt of this pin only for this port
exti_enable_request(uart_soft_rx_states[rx]->exti); // enable external interrupt
exti_set_trigger(uart_soft_rx_states[rx]->exti, EXTI_TRIGGER_BOTH); // trigger when button is pressed
nvic_enable_irq(uart_soft_rx_states[rx]->irq); // enable interrupt
@ -149,13 +149,13 @@ bool uart_soft_setup(uint32_t *rx_baudrates, uint32_t *tx_baudrates)
}
// save UART transmit definition
#if defined(UART_SOFT_TX_PORT0) && defined(UART_SOFT_TX_PIN0)
#if defined(UART_SOFT_TX_PORT0) && defined(UART_SOFT_TX_PIN0)
uart_soft_tx_states[0] = calloc(1,sizeof(struct soft_uart_tx_state)); // create state definition
uart_soft_tx_states[0]->port = GPIO(UART_SOFT_TX_PORT0); // save receive port
uart_soft_tx_states[0]->pin = GPIO(UART_SOFT_TX_PIN0); // save receive pin
uart_soft_tx_states[0]->rcc = RCC_GPIO(UART_SOFT_TX_PORT0); // save receive port peripheral clock
#endif
// setup UART transmit GPIO
for (uint8_t tx=0; tx<4; tx++) {
if (!uart_soft_tx_states[tx]) { // verify is transmit UART is defined
@ -291,7 +291,7 @@ void uart_soft_putbyte_nonblocking(uint8_t uart, uint8_t byte)
{
if (uart>=4 || !uart_soft_tx_states[uart]) { // ensure transmit UART port is defined
return; // return
}
}
while (uart_soft_tx_states[uart]->buffer_used>=LENGTH(uart_soft_tx_states[uart]->buffer)) { // idle until there is place in the buffer
__WFI(); // sleep until something happened
}

View File

@ -251,7 +251,7 @@ static void usb_disconnect(void)
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9);
gpio_set(GPIOB, GPIO9);
for (uint32_t i = 0; i < 0x2000; i++) { // wait for at least 10 ms
__asm__("nop");
__asm__("nop");
}
#else
// pull USB D+ low for a short while
@ -259,7 +259,7 @@ static void usb_disconnect(void)
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
gpio_clear(GPIOA, GPIO12);
for (uint32_t i = 0; i < 0x2000; i++) { // wait for at least 10 ms
__asm__("nop");
__asm__("nop");
}
#endif
}
@ -292,7 +292,7 @@ static enum usbd_request_return_codes usb_cdcacm_control_request(usbd_device *us
if (usb_dfu_interface.bInterfaceNumber==req->wIndex) { // check if request is for DFU
switch (req->bRequest) {
case DFU_DETACH: // USB detach requested
*complete = usb_dfu_detach; // detach after reply
*complete = usb_dfu_detach; // detach after reply
break;
case DFU_GETSTATUS: // get status
(*buf)[0] = DFU_STATUS_OK;; // set OK status
@ -355,7 +355,7 @@ static void usb_cdcacm_data_rx_cb(usbd_device *usbd_dev, uint8_t ep)
char usb_data[USB_DATA_TRANSFER_SIZE] = {0}; // buffer to read data
uint16_t usb_length = 0; // length of incoming data
// receive data
usb_length = usbd_ep_read_packet(usbd_dev, usb_cdcacm_data_endpoints[0].bEndpointAddress, usb_data, sizeof(usb_data));
if (usb_length) { // copy received data
@ -398,7 +398,7 @@ static void usb_cdcacm_data_tx_cb(usbd_device *usbd_dev, uint8_t ep)
}
/** USB CDC ACM communication callback
* @note if transmission happens before the control setting is complete with a response form the communication endpoint, Linux echoes back the data
* @note if transmission happens before the control setting is complete with a response form the communication endpoint, Linux echoes back the data
* @param[in] usbd_dev USB device descriptor
* @param[in] ep endpoint where data came in
*/
@ -438,8 +438,8 @@ void usb_cdcacm_setup(void)
usb_device = usbd_init(&st_usbfs_v1_usb_driver, &usb_cdcacm_device_descriptor, &usb_cdcacm_configuration_descriptor, usb_strings, LENGTH(usb_strings), usbd_control_buffer, sizeof(usbd_control_buffer));
usbd_register_set_config_callback(usb_device, usb_cdcacm_set_config);
nvic_enable_irq(NVIC_USB_LP_CAN_RX0_IRQ); // enable interrupts (to not have to poll all the time)
// reset buffer states
// reset buffer states
tx_i = 0;
tx_used = 0;
tx_lock = false; // release lock

View File

@ -27,5 +27,5 @@ void usb_cdcacm_setup(void);
/** send character over USB (non-blocking)
* @param[in] c character to send
* @note blocks if transmit buffer is full, else puts in buffer and returns
*/
*/
void usb_cdcacm_putchar(char c);

View File

@ -120,8 +120,8 @@ static const struct usb_config_descriptor usb_dfu_configuration = {
*/
static const char *usb_dfu_strings[] = {
"CuVoodoo", /**< manufacturer string */
"CuVoodoo STM32F1xx DFU bootloader", /**< product string */
"DFU bootloader (DFU mode)", /**< DFU interface string */
"CuVoodoo STM32F1xx DFU bootloader", /**< product string */
"DFU bootloader (DFU mode)", /**< DFU interface string */
};
/** disconnect USB to force re-enumerate */
@ -235,7 +235,7 @@ static enum usbd_request_return_codes usb_dfu_control_request(usbd_device *usbd_
}
if (*len % 2) { // we can only write half words
download_data[*len++] = 0xff; // leave flash untouched
}
}
usb_dfu_state = STATE_DFU_DNLOAD_SYNC; // go to sync state
*complete = usb_dfu_flash; // start flashing the downloaded data
}
@ -257,7 +257,7 @@ static enum usbd_request_return_codes usb_dfu_control_request(usbd_device *usbd_
} else if (STATE_DFU_MANIFEST_SYNC == usb_dfu_state) {
usb_dfu_state = STATE_DFU_MANIFEST; // go to manifest mode
led_off(); // indicate the end
*complete = usb_dfu_reset; // start reset without waiting for request since we advertised we would detach
*complete = usb_dfu_reset; // start reset without waiting for request since we advertised we would detach
}
break;
case DFU_CLRSTATUS: // clear status

View File

@ -293,7 +293,7 @@ static const uint8_t pict5x7[][5] = {
static uint16_t driver_data[VFD_MATRIX][VFD_DRIVERS*2] = {0};
/** which driver data is being transmitted */
static volatile uint8_t spi_i = 0;
/** which grid/part to activate
/** which grid/part to activate
* @note digits and matrix can be combined
*/
static volatile uint8_t vfd_grid = 0;
@ -309,7 +309,7 @@ void vfd_digit(uint8_t nb, char c)
}
uint32_t digit_data = 0; // the data to be shifted out for the driver (for the second driver)
digit_data = 1<<(4+(9-nb)); // select digit
/* encode segment
* here the bit order (classic 7 segment + underline and dot)
@ -327,7 +327,7 @@ void vfd_digit(uint8_t nb, char c)
if (false) { // add the comma (not encoded)
digit_data |= (1<<(16));
}
c &= 0x7f; // only take the ASCII part
if (c>=' ') { // only take printable characters
uint8_t i = c-' '; // get index for character
@ -345,19 +345,19 @@ void vfd_digit(uint8_t nb, char c)
void vfd_matrix(uint8_t nb, char c)
{
// check the matrix exists
if (!(nb<VFD_MATRIX)) {
if (!(nb<VFD_MATRIX)) {
return;
}
}
uint32_t matrix_data[VFD_DRIVERS] = {0}; // the data to be shifted out for the driver
// select matrix
if (nb<4) {
matrix_data[1] = 1<<(3-nb);
matrix_data[1] = 1<<(3-nb);
} else {
matrix_data[0] = 1<<(35-nb);
}
if ((c<0x80) && (c>=' ')) { // only take printable characters
uint8_t i = c-' '; // get index for character
if (i<LENGTH(font5x7)) {
@ -423,10 +423,10 @@ void vfd_setup(void)
rcc_periph_clock_enable(VFD_PORT_RCC); // enable clock for VFD GPIO
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_STR); // set VFD pin to output push-pull
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_NLE); // set VFD pin to output push-pull
gpio_set(VFD_PORT, VFD_STR); // disable HV output
gpio_clear(VFD_PORT, VFD_NLE); // do not output latched data
/* setup SPI to transmit data */
rcc_periph_clock_enable(VFD_SPI_RCC); // enable SPI clock
rcc_periph_clock_enable(VFD_SPI_PORT_RCC); // enable clock for VFD SPI GPIO
@ -451,12 +451,12 @@ void vfd_setup(void)
* when hardware NSS is used and output is enabled NSS never goes up after transmission, even if SPI is disabled
* when software NSS is used, NSS can not be set high again, even when writing to the register
* the slave select must be done manually using GPIO */
spi_enable_software_slave_management(VFD_SPI);
spi_enable_software_slave_management(VFD_SPI);
spi_set_nss_high(VFD_SPI); // set NSS high
nvic_enable_irq(VFD_SPI_IRQ); // enable SPI interrupt
nvic_enable_irq(VFD_SPI_IRQ); // enable SPI interrupt
spi_enable(VFD_SPI); // enable SPI (the tx empty interrupt will trigger)
/* setup timer to refresh display */
rcc_periph_clock_enable(VFD_TIMER_RCC); // enable clock for timer block
timer_reset(VFD_TIMER); // reset timer state
@ -465,7 +465,7 @@ void vfd_setup(void)
timer_set_period(VFD_TIMER, 0xffff/LENGTH(driver_data)/100); // set the refresh frequency
timer_enable_irq(VFD_TIMER, TIM_DIER_UIE); // enable interrupt for timer
nvic_enable_irq(VFD_TIMER_IRQ); // allow interrupt for timer
vfd_clear(); // initialize values
}