Coding conventions

Just modified some files to respect coding conventions
This commit is contained in:
DESKTOP-PU0QGTF\Fer 2018-10-12 21:19:07 +02:00
parent 3dc51a49a6
commit 5d40f334ab
6 changed files with 150 additions and 171 deletions

View File

@ -19,23 +19,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "led.h" #include "led.h"
void led_set(uint8_t usb_led) void led_set(uint8_t usb_led){
{
if (usb_led & (1<<USB_LED_CAPS_LOCK)) { if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
/* generic STM32F103C8T6 board */ /* generic STM32F103C8T6 board */
#ifdef BOARD_GENERIC_STM32_F103 #ifdef BOARD_GENERIC_STM32_F103
palClearPad(GPIOC, 13); palClearPad(GPIOC, 13);
#endif #endif
} else { } else {
/* generic STM32F103C8T6 board */ /* generic STM32F103C8T6 board */
#ifdef BOARD_GENERIC_STM32_F103 #ifdef BOARD_GENERIC_STM32_F103
palSetPad(GPIOC, 13); palSetPad(GPIOC, 13);
#endif #endif
} }
} }
// inline void gh60_caps_led_off(void) { DDRB &= ~(1<<2); PORTB &= ~(1<<2); } // inline void gh60_caps_led_off(void) { DDRB &= ~(1<<2); PORTB &= ~(1<<2); }
// inline void gh60_caps_led_on(void) { DDRB |= (1<<2); PORTB &= ~(1<<2); } // inline void gh60_caps_led_on(void) { DDRB |= (1<<2); PORTB &= ~(1<<2); }

View File

@ -27,7 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "matrix.h" #include "matrix.h"
#include "wait.h" #include "wait.h"
//#include "pwm.c" //#include "pwm.c"
#ifndef DEBOUNCE #ifndef DEBOUNCE
@ -44,16 +43,11 @@ static void init_cols(void);
static void unselect_rows(void); static void unselect_rows(void);
static void select_row(uint8_t row); static void select_row(uint8_t row);
inline uint8_t matrix_rows(void){
inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS; return MATRIX_ROWS;
} }
inline inline uint8_t matrix_cols(void){
uint8_t matrix_cols(void)
{
return MATRIX_COLS; return MATRIX_COLS;
} }
@ -69,13 +63,11 @@ void matrix_init(void)
// initialize row and col // initialize row and col
unselect_rows(); unselect_rows();
init_cols(); init_cols();
// initialize matrix state: all keys off // initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) { for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0; matrix[i] = 0;
matrix_debouncing[i] = 0; matrix_debouncing[i] = 0;
} }
//debug //debug
debug_matrix = true; debug_matrix = true;
LED_ON(); LED_ON();
@ -83,8 +75,7 @@ void matrix_init(void)
LED_OFF(); LED_OFF();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void){
{
for (uint8_t i = 0; i < MATRIX_ROWS; i++) { for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
select_row(i); select_row(i);
wait_us(30); // without this wait read unstable value. wait_us(30); // without this wait read unstable value.
@ -112,20 +103,15 @@ uint8_t matrix_scan(void)
return 1; return 1;
} }
inline inline bool matrix_is_on(uint8_t row, uint8_t col){
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col)); return (matrix[row] & ((matrix_row_t)1<<col));
} }
inline inline matrix_row_t matrix_get_row(uint8_t row){
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row]; return matrix[row];
} }
void matrix_print(void) void matrix_print(void){
{
print("\nr/c 0123456789ABCDEF\n"); print("\nr/c 0123456789ABCDEF\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": "); phex(row); print(": ");
@ -137,8 +123,7 @@ void matrix_print(void)
/* Column pin configuration /* Column pin configuration
*/ */
// Modified by Xydane // Modified by Xydane
static void init_cols(void) static void init_cols(void){
{
palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_PULLUP); palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_PULLUP);
palSetPadMode(GPIOA, 15, PAL_MODE_INPUT_PULLUP); palSetPadMode(GPIOA, 15, PAL_MODE_INPUT_PULLUP);
palSetPadMode(GPIOA, 10, PAL_MODE_INPUT_PULLUP); palSetPadMode(GPIOA, 10, PAL_MODE_INPUT_PULLUP);
@ -158,8 +143,7 @@ static void init_cols(void)
/* Returns status of switches(1:on, 0:off) */ /* Returns status of switches(1:on, 0:off) */
// Modified by Xydane // Modified by Xydane
static matrix_row_t read_cols(void) static matrix_row_t read_cols(void){
{
return ((palReadPad(GPIOA, 5)==PAL_HIGH) ? 0 : (1<<0)) return ((palReadPad(GPIOA, 5)==PAL_HIGH) ? 0 : (1<<0))
| ((palReadPad(GPIOA, 15)==PAL_HIGH) ? 0 : (1<<1)) | ((palReadPad(GPIOA, 15)==PAL_HIGH) ? 0 : (1<<1))
| ((palReadPad(GPIOA, 10)==PAL_HIGH) ? 0 : (1<<2)) | ((palReadPad(GPIOA, 10)==PAL_HIGH) ? 0 : (1<<2))
@ -180,8 +164,7 @@ static matrix_row_t read_cols(void)
/* Row pin configuration /* Row pin configuration
*/ */
// Modified by Xydane // Modified by Xydane
static void unselect_rows(void) static void unselect_rows(void){
{
palSetPadMode(GPIOB, 9, PAL_MODE_INPUT); palSetPadMode(GPIOB, 9, PAL_MODE_INPUT);
palSetPadMode(GPIOB, 8, PAL_MODE_INPUT); palSetPadMode(GPIOB, 8, PAL_MODE_INPUT);
palSetPadMode(GPIOB, 7, PAL_MODE_INPUT); palSetPadMode(GPIOB, 7, PAL_MODE_INPUT);
@ -191,8 +174,7 @@ static void unselect_rows(void)
} }
// Modified by Xydane // Modified by Xydane
static void select_row(uint8_t row) static void select_row(uint8_t row){
{
(void)row; (void)row;
switch (row) { switch (row) {
case 0: case 0: