Skip to content

Commit

Permalink
使用pragma once 代替 ifdef/endif
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-kirisame committed Aug 9, 2019
1 parent 95b1a4f commit 020d2b9
Show file tree
Hide file tree
Showing 30 changed files with 34 additions and 135 deletions.
6 changes: 1 addition & 5 deletions application/main/src/ble/ble_bas_service.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#ifndef __BLE_BAS_SERVICE_H__
#define __BLE_BAS_SERVICE_H__

#pragma once
#include <stdint.h>

void battery_timer_start(void);
void battery_service_init(void);

#endif // __BLE_BAS_SERVICE_H__
6 changes: 1 addition & 5 deletions application/main/src/ble/ble_config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if !defined(__BLE_CONFIG_H__)
#define __BLE_CONFIG_H__

#pragma once
#include "../config/keyboard_config.h"

#ifdef PASSKEY_REQUIRED
Expand All @@ -22,5 +20,3 @@

#define DEVICE_NAME PRODUCT
#define MANUFACTURER_NAME MANUFACTURER

#endif // __BLE_CONFIG_H__
5 changes: 1 addition & 4 deletions application/main/src/ble/ble_hid_service.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __BLE_HID_SERVICE_H__
#define __BLE_HID_SERVICE_H__
#pragma once

#include <stdint.h>
#include "ble_services.h"
Expand All @@ -10,5 +9,3 @@ void hid_event_handler(enum user_ble_event arg);
void keys_send(uint8_t report_index, uint8_t key_pattern_len, uint8_t* p_key_pattern);

extern uint8_t keyboard_led_val_ble;

#endif //__BLE_HID_SERVICE_H__
5 changes: 1 addition & 4 deletions application/main/src/ble/ble_services.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __BLE_SERVICES__
#define __BLE_SERVICES__
#pragma once

#include "ble.h"
#include "../main.h"
Expand Down Expand Up @@ -35,5 +34,3 @@ void advertising_start(bool erase_bonds);
void ble_passkey_send(uint8_t const * p_key);

void advertising_slow(void);

#endif
5 changes: 1 addition & 4 deletions application/main/src/config/keyboard_config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __KEYBOARD_CONFIG_H__
#define __KEYBOARD_CONFIG_H__
#pragma once

#include "config.h"

Expand All @@ -16,5 +15,3 @@
#define LED_CLEAR(x) nrf_gpio_pin_set(x)
#define LED_WRITE(x, b) nrf_gpio_pin_write(x, !(b))
#endif

#endif //__KEYBOARD_CONFIG_H__
6 changes: 1 addition & 5 deletions application/main/src/keyboard/ble_keyboard.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#if !defined(_BLE_KEYBOARD_H_)
#define _BLE_KEYBOARD_H_
#pragma once

#include <stdbool.h>

void ble_keyboard_init(void);
void ble_keyboard_timer_start(void);
void ble_keyboard_powersave(bool save);
void keyboard_debounce(void);

#endif // _BLE_KEYBOARD_H_

7 changes: 1 addition & 6 deletions application/main/src/keyboard/custom_hook.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#ifndef __CUSTOM_HOOK__
#define __CUSTOM_HOOK__

#pragma once
#include "report.h"
void hook_send_keyboard(report_keyboard_t * report);

#endif

6 changes: 1 addition & 5 deletions application/main/src/keyboard/keyboard_fn.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#ifndef __KEYBOARD_FN__
#define __KEYBOARD_FN__

#pragma once
#include "action.h"

enum fn_functions {
POWER_SLEEP,
SWITCH_USB,
};

#endif
5 changes: 1 addition & 4 deletions application/main/src/keyboard/keyboard_host_driver.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef __KEYBOARD_HOST_DRIVER__
#define __KEYBOARD_HOST_DRIVER__
#pragma once

#include "host.h"
#include "host_driver.h"

extern host_driver_t driver;

#endif
5 changes: 1 addition & 4 deletions application/main/src/keyboard/keyboard_led.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __KEYBOARD_LED_H_
#define __KEYBOARD_LED_H_
#pragma once

#include <stdint.h>
#include "../config/keyboard_config.h"
Expand Down Expand Up @@ -32,5 +31,3 @@ void keyboard_led_deinit();
* @brief 启用自动熄灭的计时器
*/
void off_timer_start();

#endif //__KEYBOARD_LED_H_
6 changes: 1 addition & 5 deletions application/main/src/keyboard/keyboard_matrix.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#ifndef __KEYBOARD_MATRIX__
#define __KEYBOARD_MATRIX__

#pragma once
void matrix_sleep_prepare(void);

#endif
6 changes: 1 addition & 5 deletions application/main/src/keyboard/keymap_storage.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#if !defined(__KEYMAP_STORAGE_H__)
#define __KEYMAP_STORAGE_H__

#pragma once
#include <stdint.h>
#include <stdbool.h>

void keymap_init(void);
bool keymap_set(uint8_t block, uint8_t size, uint8_t* data);

#endif // __KEYMAP_STORAGE_H__
8 changes: 2 additions & 6 deletions application/main/src/keyboard/passkey.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#ifndef __PASSKEY_H__
#define __PASSKEY_H__

void passkey_req_handler(void);

#endif // _PASSKEY_H__
#pragma once
void passkey_req_handler(void);
5 changes: 1 addition & 4 deletions application/main/src/keyboard/queue.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __APP_QUEUE_H__
#define __APP_QUEUE_H__
#pragma once

#define QUEUE(TYPE, NAME, SIZE) \
TYPE NAME[SIZE];\
Expand Down Expand Up @@ -33,5 +32,3 @@
{\
NAME##_front = 0; NAME##_rear = 0; NAME##_full = false;\
}

#endif // __APP_QUEUE_H__
6 changes: 1 addition & 5 deletions application/main/src/keyboard/sleep_reason.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#if !defined(__SLEEP_REASON__H)
#define __SLEEP_REASON__H

#pragma once
#include <stdbool.h>

bool sleep_reason_get(void);
void sleep_reason_set(bool val);

#endif // __SLEEP_REASON__H
5 changes: 1 addition & 4 deletions application/main/src/keyboard/usb_comm.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if !defined(__USB_COMM_H__)
#define __USB_COMM_H__
#pragma once

#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -50,5 +49,3 @@ void usb_comm_switch(void);
* @brief 当前USB的键盘状态灯
*/
extern uint8_t keyboard_led_val_usb;

#endif // __USB_COMM_H__
5 changes: 1 addition & 4 deletions application/main/src/keyboard/wait_api.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef WAIT_API_H
#define WAIT_API_H
#pragma once

#ifdef __cplusplus
extern "C" {
Expand All @@ -12,5 +11,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif

#endif
5 changes: 1 addition & 4 deletions application/main/src/main.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#pragma once

#include <stdbool.h>

Expand Down Expand Up @@ -48,5 +47,3 @@ enum user_ble_event {
void ble_user_event(enum user_ble_event arg);
void sleep(enum SLEEP_REASON reason);
extern bool erase_bonds;

#endif // __MAIN_H__
8 changes: 2 additions & 6 deletions application/main/src/protocol/lufa/descriptor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#ifndef __DESCRIPTOR_H_REP__
#define __DESCRIPTOR_H_REP__

#include "config.h"

#endif
#pragma once
#include "config.h"
5 changes: 1 addition & 4 deletions keyboard/lot60-ble/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CONFIG_H
#define CONFIG_H
#pragma once

#include <stdint.h>

Expand Down Expand Up @@ -118,5 +117,3 @@ static const uint8_t column_pin_array[MATRIX_COLS] = { 16, 15, 14, 13, 12, 11, 2
#define ROW_IN // 二极管方向是从COL->ROW

#define LED_POSITIVE // LED上拉驱动

#endif
5 changes: 1 addition & 4 deletions keyboard/lot60-ble/keymap_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 定义各个按键的位置,方便编写Keymap
*/
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H
#pragma once

#include <stdint.h>
#include "keymap.h"
Expand Down Expand Up @@ -76,5 +75,3 @@ extern const action_t fn_actions[];
K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \
)

#endif
5 changes: 1 addition & 4 deletions keyboard/lot60-ble/led_rgb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __LED_RGB_H__
#define __LED_RGB_H__
#pragma once
#include <stdbool.h>

/**
Expand Down Expand Up @@ -28,5 +27,3 @@ void keyboard_led_rgb_init(void);
* @param on
*/
void keyboard_led_rgb_switch(bool on);

#endif //__LED_RGB_H__
5 changes: 1 addition & 4 deletions usb/app_timer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __APP_TIMER_H_
#define __APP_TIMER_H_
#pragma once

#include <stdint.h>
#include <stdbool.h>
Expand All @@ -19,5 +18,3 @@ typedef struct
void timer_tick(void);
void timer_task_exec(void);
void timer_create(task_t task, bool repeat, uint16_t period);

#endif // __APP_TIMER_H_
5 changes: 1 addition & 4 deletions usb/descriptor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __DESCRIPTOR_H__
#define __DESCRIPTOR_H__
#pragma once

/** \brief 获取USB各种描述符
*
Expand All @@ -10,5 +9,3 @@
*
*/
uint8_t GetUsbDescriptor(uint8_t type1, uint8_t type2, uint8_t index, uint8_t **strPtr);

#endif // __DESCRIPTOR_H__
6 changes: 2 additions & 4 deletions usb/endpoints.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __ENDPOINTS_H__
#define __ENDPOINTS_H__
#pragma once

#include <stdint.h>
#include <stdbool.h>

Expand Down Expand Up @@ -54,5 +54,3 @@ extern void nop();
#define USB_SOF_EP2 nop
#define USB_SOF_EP3 nop
#define USB_SOF_EP4 nop

#endif // __ENDPOINTS_H__
5 changes: 1 addition & 4 deletions usb/interrupt.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __INTERRUPT_H__
#define __INTERRUPT_H__
#pragma once

#include <stdbool.h>

Expand All @@ -10,5 +9,3 @@
*/
void UsbIsr();
void UsbSuspendEvt(bool sleep);

#endif // __INTERRUPT_H__
5 changes: 1 addition & 4 deletions usb/system.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __SYSTEM_H__
#define __SYSTEM_H__
#pragma once

#include <stdint.h>
#define FREQ_SYS 24000000
Expand All @@ -9,5 +8,3 @@ void CfgSysClock();
void DelayMs(uint16_t n);
void PrintHex(uint8_t *data, uint8_t len);
int putchar(int c);

#endif // __SYSTEM_H__
5 changes: 1 addition & 4 deletions usb/uart.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __UART__DRIVER__
#define __UART__DRIVER__
#pragma once

#include <stdint.h>
#include <stdbool.h>
Expand Down Expand Up @@ -39,5 +38,3 @@ typedef enum
extern uart_state uart_rx_state;

extern bool usb_evt;

#endif // __UART__DRIVER__
5 changes: 1 addition & 4 deletions usb/usb_comm.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#ifndef __USB_COMM__
#define __USB_COMM__
#pragma once

#include <stdint.h>
#include <stdbool.h>

void KeyboardGenericUpload(uint8_t * packet, uint8_t len);
void KeyboardExtraUpload(uint8_t * packet, uint8_t len);
void ResponseConfigurePacket(uint8_t * packet, uint8_t len);

#endif // __USB_COMM__
8 changes: 2 additions & 6 deletions usb/usb_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef __USB_DESCRIPTOR__
#define __USB_DESCRIPTOR__
#pragma once

#include <stdint.h>
#include "config.h"

Expand Down Expand Up @@ -370,7 +370,3 @@ uint8_t const report_desc_HID2[]=
0x91 ,0x02, // Ouput (Data,Var,Abs)
0xc0 // end Application Collection
};



#endif // __USB_DESCRIPTOR__

0 comments on commit 020d2b9

Please sign in to comment.