1
0
Fork 0

clang-format changes

This commit is contained in:
skullY 2019-08-30 11:19:03 -07:00 committed by skullydazed
parent 61af76a10d
commit b624f32f94
502 changed files with 32259 additions and 39062 deletions

View file

@ -18,34 +18,40 @@
#include "samd51j18a.h"
#include "md_bootloader.h"
//Set watchdog timer to reset. Directs the bootloader to stay in programming mode.
// Set watchdog timer to reset. Directs the bootloader to stay in programming mode.
void bootloader_jump(void) {
#ifdef KEYBOARD_massdrop_ctrl
//CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method.
uint8_t ver_ram_method[] = "v2.18Jun 22 2018 17:28:08"; //The version to match (NULL terminated by compiler)
uint8_t *ver_check = ver_ram_method; //Pointer to version match string for traversal
uint8_t *ver_rom = (uint8_t *)0x21A0; //Pointer to address in ROM where this specific bootloader version would exist
// CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method.
uint8_t ver_ram_method[] = "v2.18Jun 22 2018 17:28:08"; // The version to match (NULL terminated by compiler)
uint8_t *ver_check = ver_ram_method; // Pointer to version match string for traversal
uint8_t *ver_rom = (uint8_t *)0x21A0; // Pointer to address in ROM where this specific bootloader version would exist
while (*ver_check && *ver_rom == *ver_check) { //While there are check version characters to match and bootloader's version matches check's version
ver_check++; //Move check version pointer to next character
ver_rom++; //Move ROM version pointer to next character
while (*ver_check && *ver_rom == *ver_check) { // While there are check version characters to match and bootloader's version matches check's version
ver_check++; // Move check version pointer to next character
ver_rom++; // Move ROM version pointer to next character
}
if (!*ver_check) { //If check version pointer is NULL, all characters have matched
*MAGIC_ADDR = BOOTLOADER_MAGIC; //Set magic number into RAM
NVIC_SystemReset(); //Perform system reset
while (1) {} //Won't get here
if (!*ver_check) { // If check version pointer is NULL, all characters have matched
*MAGIC_ADDR = BOOTLOADER_MAGIC; // Set magic number into RAM
NVIC_SystemReset(); // Perform system reset
while (1) {
} // Won't get here
}
#endif
WDT->CTRLA.bit.ENABLE = 0;
while (WDT->SYNCBUSY.bit.ENABLE) {}
while (WDT->CTRLA.bit.ENABLE) {}
WDT->CONFIG.bit.WINDOW = 0;
WDT->CONFIG.bit.PER = 0;
while (WDT->SYNCBUSY.bit.ENABLE) {
}
while (WDT->CTRLA.bit.ENABLE) {
}
WDT->CONFIG.bit.WINDOW = 0;
WDT->CONFIG.bit.PER = 0;
WDT->EWCTRL.bit.EWOFFSET = 0;
WDT->CTRLA.bit.ENABLE = 1;
while (WDT->SYNCBUSY.bit.ENABLE) {}
while (!WDT->CTRLA.bit.ENABLE) {}
while (1) {} //Wait on timeout
WDT->CTRLA.bit.ENABLE = 1;
while (WDT->SYNCBUSY.bit.ENABLE) {
}
while (!WDT->CTRLA.bit.ENABLE) {
}
while (1) {
} // Wait on timeout
}

View file

@ -21,78 +21,75 @@
static uint8_t buffer[EEPROM_SIZE];
uint8_t eeprom_read_byte(const uint8_t *addr) {
uintptr_t offset = (uintptr_t)addr;
return buffer[offset];
uintptr_t offset = (uintptr_t)addr;
return buffer[offset];
}
void eeprom_write_byte(uint8_t *addr, uint8_t value) {
uintptr_t offset = (uintptr_t)addr;
buffer[offset] = value;
uintptr_t offset = (uintptr_t)addr;
buffer[offset] = value;
}
uint16_t eeprom_read_word(const uint16_t *addr) {
const uint8_t *p = (const uint8_t *)addr;
return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8);
const uint8_t *p = (const uint8_t *)addr;
return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8);
}
uint32_t eeprom_read_dword(const uint32_t *addr) {
const uint8_t *p = (const uint8_t *)addr;
return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8)
| (eeprom_read_byte(p+2) << 16) | (eeprom_read_byte(p+3) << 24);
const uint8_t *p = (const uint8_t *)addr;
return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8) | (eeprom_read_byte(p + 2) << 16) | (eeprom_read_byte(p + 3) << 24);
}
void eeprom_read_block(void *buf, const void *addr, uint32_t len) {
const uint8_t *p = (const uint8_t *)addr;
uint8_t *dest = (uint8_t *)buf;
while (len--) {
*dest++ = eeprom_read_byte(p++);
}
const uint8_t *p = (const uint8_t *)addr;
uint8_t * dest = (uint8_t *)buf;
while (len--) {
*dest++ = eeprom_read_byte(p++);
}
}
void eeprom_write_word(uint16_t *addr, uint16_t value) {
uint8_t *p = (uint8_t *)addr;
eeprom_write_byte(p++, value);
eeprom_write_byte(p, value >> 8);
uint8_t *p = (uint8_t *)addr;
eeprom_write_byte(p++, value);
eeprom_write_byte(p, value >> 8);
}
void eeprom_write_dword(uint32_t *addr, uint32_t value) {
uint8_t *p = (uint8_t *)addr;
eeprom_write_byte(p++, value);
eeprom_write_byte(p++, value >> 8);
eeprom_write_byte(p++, value >> 16);
eeprom_write_byte(p, value >> 24);
uint8_t *p = (uint8_t *)addr;
eeprom_write_byte(p++, value);
eeprom_write_byte(p++, value >> 8);
eeprom_write_byte(p++, value >> 16);
eeprom_write_byte(p, value >> 24);
}
void eeprom_write_block(const void *buf, void *addr, uint32_t len) {
uint8_t *p = (uint8_t *)addr;
const uint8_t *src = (const uint8_t *)buf;
while (len--) {
eeprom_write_byte(p++, *src++);
}
uint8_t * p = (uint8_t *)addr;
const uint8_t *src = (const uint8_t *)buf;
while (len--) {
eeprom_write_byte(p++, *src++);
}
}
void eeprom_update_byte(uint8_t *addr, uint8_t value) {
eeprom_write_byte(addr, value);
}
void eeprom_update_byte(uint8_t *addr, uint8_t value) { eeprom_write_byte(addr, value); }
void eeprom_update_word(uint16_t *addr, uint16_t value) {
uint8_t *p = (uint8_t *)addr;
eeprom_write_byte(p++, value);
eeprom_write_byte(p, value >> 8);
uint8_t *p = (uint8_t *)addr;
eeprom_write_byte(p++, value);
eeprom_write_byte(p, value >> 8);
}
void eeprom_update_dword(uint32_t *addr, uint32_t value) {
uint8_t *p = (uint8_t *)addr;
eeprom_write_byte(p++, value);
eeprom_write_byte(p++, value >> 8);
eeprom_write_byte(p++, value >> 16);
eeprom_write_byte(p, value >> 24);
uint8_t *p = (uint8_t *)addr;
eeprom_write_byte(p++, value);
eeprom_write_byte(p++, value >> 8);
eeprom_write_byte(p++, value >> 16);
eeprom_write_byte(p, value >> 24);
}
void eeprom_update_block(const void *buf, void *addr, uint32_t len) {
uint8_t *p = (uint8_t *)addr;
const uint8_t *src = (const uint8_t *)buf;
while (len--) {
eeprom_write_byte(p++, *src++);
}
uint8_t * p = (uint8_t *)addr;
const uint8_t *src = (const uint8_t *)buf;
while (len--) {
eeprom_write_byte(p++, *src++);
}
}

View file

@ -17,50 +17,52 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef CONSOLE_ENABLE
#include "samd51j18a.h"
#include "arm_atsam_protocol.h"
#include "printf.h"
#include <string.h>
#include <stdarg.h>
# include "samd51j18a.h"
# include "arm_atsam_protocol.h"
# include "printf.h"
# include <string.h>
# include <stdarg.h>
void console_printf(char *fmt, ...) {
while (udi_hid_con_b_report_trans_ongoing) {} //Wait for any previous transfers to complete
while (udi_hid_con_b_report_trans_ongoing) {
} // Wait for any previous transfers to complete
static char console_printbuf[CONSOLE_PRINTBUF_SIZE]; //Print and send buffer
va_list va;
int result;
static char console_printbuf[CONSOLE_PRINTBUF_SIZE]; // Print and send buffer
va_list va;
int result;
va_start(va, fmt);
result = vsnprintf(console_printbuf, CONSOLE_PRINTBUF_SIZE, fmt, va);
va_end(va);
uint32_t irqflags;
char *pconbuf = console_printbuf; //Pointer to start send from
int send_out = CONSOLE_EPSIZE; //Bytes to send per transfer
char * pconbuf = console_printbuf; // Pointer to start send from
int send_out = CONSOLE_EPSIZE; // Bytes to send per transfer
while (result > 0) { //While not error and bytes remain
while (udi_hid_con_b_report_trans_ongoing) {} //Wait for any previous transfers to complete
while (result > 0) { // While not error and bytes remain
while (udi_hid_con_b_report_trans_ongoing) {
} // Wait for any previous transfers to complete
irqflags = __get_PRIMASK();
__disable_irq();
__DMB();
if (result < CONSOLE_EPSIZE) { //If remaining bytes are less than console epsize
memset(udi_hid_con_report, 0, CONSOLE_EPSIZE); //Clear the buffer
send_out = result; //Send remaining size
if (result < CONSOLE_EPSIZE) { // If remaining bytes are less than console epsize
memset(udi_hid_con_report, 0, CONSOLE_EPSIZE); // Clear the buffer
send_out = result; // Send remaining size
}
memcpy(udi_hid_con_report, pconbuf, send_out); //Copy data into the send buffer
memcpy(udi_hid_con_report, pconbuf, send_out); // Copy data into the send buffer
udi_hid_con_b_report_valid = 1; //Set report valid
udi_hid_con_send_report(); //Send report
udi_hid_con_b_report_valid = 1; // Set report valid
udi_hid_con_send_report(); // Send report
__DMB();
__set_PRIMASK(irqflags);
result -= send_out; //Decrement result by bytes sent
pconbuf += send_out; //Increment buffer point by bytes sent
result -= send_out; // Decrement result by bytes sent
pconbuf += send_out; // Increment buffer point by bytes sent
}
}
#endif //CONSOLE_ENABLE
#endif // CONSOLE_ENABLE

View file

@ -7,5 +7,4 @@ void console_printf(char *fmt, ...);
#define __xprintf console_printf
#endif //_PRINTF_H_
#endif //_PRINTF_H_

View file

@ -7,44 +7,35 @@
*
* FIXME: needs doc
*/
void suspend_idle(uint8_t time) {
/* Note: Not used anywhere currently */
}
void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */ }
/** \brief Run user level Power down
*
* FIXME: needs doc
*/
__attribute__ ((weak))
void suspend_power_down_user (void) {
}
__attribute__((weak)) void suspend_power_down_user(void) {}
/** \brief Run keyboard level Power down
*
* FIXME: needs doc
*/
__attribute__ ((weak))
void suspend_power_down_kb(void) {
suspend_power_down_user();
}
__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
/** \brief Suspend power down
*
* FIXME: needs doc
*/
void suspend_power_down(void)
{
void suspend_power_down(void) {
#ifdef RGB_MATRIX_ENABLE
I2C3733_Control_Set(0); //Disable LED driver
I2C3733_Control_Set(0); // Disable LED driver
#endif
suspend_power_down_kb();
}
__attribute__ ((weak)) void matrix_power_up(void) {}
__attribute__ ((weak)) void matrix_power_down(void) {}
bool suspend_wakeup_condition(void) {
__attribute__((weak)) void matrix_power_up(void) {}
__attribute__((weak)) void matrix_power_down(void) {}
bool suspend_wakeup_condition(void) {
matrix_power_up();
matrix_scan();
matrix_power_down();
@ -58,19 +49,13 @@ bool suspend_wakeup_condition(void) {
*
* FIXME: needs doc
*/
__attribute__ ((weak))
void suspend_wakeup_init_user(void) {
}
__attribute__((weak)) void suspend_wakeup_init_user(void) {}
/** \brief run keyboard level code immediately after wakeup
*
* FIXME: needs doc
*/
__attribute__ ((weak))
void suspend_wakeup_init_kb(void) {
suspend_wakeup_init_user();
}
__attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); }
/** \brief run immediately after wakeup
*
@ -78,15 +63,14 @@ void suspend_wakeup_init_kb(void) {
*/
void suspend_wakeup_init(void) {
#ifdef RGB_MATRIX_ENABLE
#ifdef USE_MASSDROP_CONFIGURATOR
# ifdef USE_MASSDROP_CONFIGURATOR
if (led_enabled) {
I2C3733_Control_Set(1);
}
#else
# else
I2C3733_Control_Set(1);
#endif
# endif
#endif
suspend_wakeup_init_kb();
}

View file

@ -2,42 +2,18 @@
#include "timer.h"
#include "tmk_core/protocol/arm_atsam/clks.h"
void set_time(uint64_t tset)
{
ms_clk = tset;
}
void set_time(uint64_t tset) { ms_clk = tset; }
void timer_init(void)
{
timer_clear();
}
void timer_init(void) { timer_clear(); }
uint16_t timer_read(void)
{
return (uint16_t)ms_clk;
}
uint16_t timer_read(void) { return (uint16_t)ms_clk; }
uint32_t timer_read32(void)
{
return (uint32_t)ms_clk;
}
uint32_t timer_read32(void) { return (uint32_t)ms_clk; }
uint64_t timer_read64(void)
{
return ms_clk;
}
uint64_t timer_read64(void) { return ms_clk; }
uint16_t timer_elapsed(uint16_t tlast)
{
return TIMER_DIFF_16(timer_read(), tlast);
}
uint16_t timer_elapsed(uint16_t tlast) { return TIMER_DIFF_16(timer_read(), tlast); }
uint32_t timer_elapsed32(uint32_t tlast)
{
return TIMER_DIFF_32(timer_read32(), tlast);
}
uint32_t timer_elapsed32(uint32_t tlast) { return TIMER_DIFF_32(timer_read32(), tlast); }
void timer_clear(void)
{
set_time(0);
}
void timer_clear(void) { set_time(0); }