From fc5fb2fc1598bd07cafb97b35100237506592d9d Mon Sep 17 00:00:00 2001
From: MechMerlin <30334081+mechmerlin@users.noreply.github.com>
Date: Sat, 7 Sep 2019 01:04:48 -0700
Subject: CA66 R1/R2 Cleanup (#6678)

* fixup readme to adhere to QMK standards and to also have more information

* use pragma once

* strip out the custom bootmagic lite routine as it is the same as QMK's default bootmagic lite routine. Also add the caps lock led indicator

* turn on bootmagic lite

* update default keymap

* Update keyboards/playkbtw/ca66/ca66.c

Co-Authored-By: fauxpark <fauxpark@gmail.com>

* remove lines 4 thru 37 and add bootloader
---
 keyboards/playkbtw/ca66/ca66.c                   | 34 ++++----------
 keyboards/playkbtw/ca66/ca66.h                   |  5 +-
 keyboards/playkbtw/ca66/config.h                 |  7 +--
 keyboards/playkbtw/ca66/keymaps/default/keymap.c | 18 -------
 keyboards/playkbtw/ca66/readme.md                | 11 +++--
 keyboards/playkbtw/ca66/rules.mk                 | 60 +++++-------------------
 6 files changed, 28 insertions(+), 107 deletions(-)

(limited to 'keyboards/playkbtw')

diff --git a/keyboards/playkbtw/ca66/ca66.c b/keyboards/playkbtw/ca66/ca66.c
index 5f61df64e5..43a648eca0 100644
--- a/keyboards/playkbtw/ca66/ca66.c
+++ b/keyboards/playkbtw/ca66/ca66.c
@@ -1,30 +1,12 @@
 #include "ca66.h"
-#include "config.h"
 
-void bootmagic_lite(void)
-{
-	// The lite version of TMK's bootmagic.
-	// 100% less potential for accidentally making the
-	// keyboard do stupid things.
+void led_set_kb(uint8_t usb_led) {
+	// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
+  if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
+    writePinHigh(D1);
+  } else {
+    writePinLow(D1);
+  }
 
-	// We need multiple scans because debouncing can't be turned off.
-	matrix_scan();
-	wait_ms(DEBOUNCE);
-	matrix_scan();
-
-	// If the Esc (matrix 0,0) is held down on power up,
-	// reset the EEPROM valid state and jump to bootloader.
-	if ( matrix_get_row(0) & (1<<0) )
-	{
-		// Set the TMK/QMK EEPROM state as invalid.
-		eeconfig_disable();
-		// Jump to bootloader.
-		bootloader_jump();
-	}
-}
-
-void matrix_init_kb(void)
-{
-	bootmagic_lite();
-	matrix_init_user();
+	led_set_user(usb_led);
 }
diff --git a/keyboards/playkbtw/ca66/ca66.h b/keyboards/playkbtw/ca66/ca66.h
index 0c00125a36..e52bdea664 100644
--- a/keyboards/playkbtw/ca66/ca66.h
+++ b/keyboards/playkbtw/ca66/ca66.h
@@ -1,5 +1,4 @@
-#ifndef CA66_H
-#define CA66_H
+#pragma once
 
 #include "quantum.h"
 
@@ -16,5 +15,3 @@
   { K300,  K301,  K302,  K303,  K304,  K305,  K306,  K307,  K308,  K309,  K310,  K311,  K312,  K313,  K314 }, \
   { KC_NO, K401,  K402,  K403,  K404,  KC_NO, K406,  KC_NO, K408,  K409,  K410,  K411,  K412,  K413,  K414 }  \
 }
-
-#endif
diff --git a/keyboards/playkbtw/ca66/config.h b/keyboards/playkbtw/ca66/config.h
index b4c0e62341..ff68cdac9e 100644
--- a/keyboards/playkbtw/ca66/config.h
+++ b/keyboards/playkbtw/ca66/config.h
@@ -1,5 +1,4 @@
-#ifndef CONFIG_H
-#define CONFIG_H
+#pragma once
 
 #include "config_common.h"
 
@@ -15,7 +14,7 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
-/* key matrix pins */
+/* key matrix pins         0   1   2   3   4   5   6   7   8   9  10  11  12  13  14*/
 #define MATRIX_ROW_PINS { F5, F4, F1, B0, B3 }
 #define MATRIX_COL_PINS { F7, C7, C6, B6, B5, B4, D7, D6, D4, D5, D3, D2, F6, B7, E6 }
 #define UNUSED_PINS
@@ -45,5 +44,3 @@
 #define RGBLIGHT_SAT_STEP 8
 #define RGBLIGHT_VAL_STEP 8
 #endif
-
-#endif
diff --git a/keyboards/playkbtw/ca66/keymaps/default/keymap.c b/keyboards/playkbtw/ca66/keymaps/default/keymap.c
index 5a3c4c8623..6f87fb0c11 100644
--- a/keyboards/playkbtw/ca66/keymaps/default/keymap.c
+++ b/keyboards/playkbtw/ca66/keymaps/default/keymap.c
@@ -16,21 +16,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     KC_LSFT, KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, RGB_HUI,                  KC_END,  
     KC_LCTL,          KC_LGUI, KC_LALT,          KC_TRNS,          KC_TRNS,          KC_TRNS, KC_TRNS, KC_TRNS, RGB_SAD, RGB_HUD, RGB_SAI),
 };
-
-void matrix_init_user(void) {
-}
-
-void matrix_scan_user(void) {
-}
-
-bool process_record_user(uint16_t keycode, keyrecord_t *record) {
-	return true;
-}
-
-void led_set_user(uint8_t usb_led) {
-	if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
-		DDRD |= (1 << 1); PORTD &= ~(1 << 1);
-	} else {
-		DDRD &= ~(1 << 1); PORTD &= ~(1 << 1);
-	}
-}
diff --git a/keyboards/playkbtw/ca66/readme.md b/keyboards/playkbtw/ca66/readme.md
index c415efd5f7..94bf0d537d 100644
--- a/keyboards/playkbtw/ca66/readme.md
+++ b/keyboards/playkbtw/ca66/readme.md
@@ -1,15 +1,16 @@
-CA66
-==
+# CA66
 
 Custom 65%
 
+This QMK firmware handles both PCBs from Round 1 and from Round 2. 
+
 Keyboard Maintainer: QMK Community   
-Hardware Supported: CA66   
-Hardware Availability: [Play Keyboard](http://play-keyboard.store/)
+Hardware Supported: CA66 R1/R2  
+Hardware Availability: [Play Keyboard](http://play-keyboard.store/)  
 
 
 Make example for this keyboard (after setting up your build environment):
 
     make playkbtw/ca66:default
 
-See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information.
+See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/keyboards/playkbtw/ca66/rules.mk b/keyboards/playkbtw/ca66/rules.mk
index 5779b2c8ad..e86f5ec038 100644
--- a/keyboards/playkbtw/ca66/rules.mk
+++ b/keyboards/playkbtw/ca66/rules.mk
@@ -1,56 +1,18 @@
 # MCU name
 MCU = atmega32u4
 
-# Processor frequency.
-#     This will define a symbol, F_CPU, in all source code files equal to the
-#     processor frequency in Hz. You can then use this symbol in your source code to
-#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-#     automatically to create a 32-bit value in your source code.
-#
-#     This will be an integer division of F_USB below, as it is sourced by
-#     F_USB after it has run through any CPU prescalers. Note that this value
-#     does not *change* the processor frequency - it should merely be updated to
-#     reflect the processor speed set externally so that the code can use accurate
-#     software delays.
-F_CPU = 16000000
-
-#
-# LUFA specific
-#
-# Target architecture (see library "Board Types" documentation).
-ARCH = AVR8
-
-# Input clock frequency.
-#     This will define a symbol, F_USB, in all source code files equal to the
-#     input clock frequency (before any prescaling is performed) in Hz. This value may
-#     differ from F_CPU if prescaling is used on the latter, and is required as the
-#     raw input clock is fed directly to the PLL sections of the AVR for high speed
-#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
-#     at the end, this will be done automatically to create a 32-bit value in your
-#     source code.
-#
-#     If no clock division is performed on the input clock inside the AVR (via the
-#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
-F_USB = $(F_CPU)
-
-# Interrupt driven control endpoint task(+60)
-OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
-
-
-# Boot Section Size in *bytes*
-OPT_DEFS += -DBOOTLOADER_SIZE=4096
-
+BOOTLOADER = atmel-dfu
 
 # Build Options
 #   comment out to disable the options.
 #
-BOOTMAGIC_ENABLE ?= no
-MOUSEKEY_ENABLE ?= yes	# Mouse keys(+4700)
-EXTRAKEY_ENABLE ?= yes	# Audio control and System control(+450)
-CONSOLE_ENABLE ?= no	# Console for debug(+400)
-COMMAND_ENABLE ?= no    # Commands for debug and configuration
-SLEEP_LED_ENABLE ?= no  # Breathing sleep LED during USB suspend
-NKRO_ENABLE ?= yes		# USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-BACKLIGHT_ENABLE ?= yes  # Enable keyboard backlight functionality
-AUDIO_ENABLE ?= no
-RGBLIGHT_ENABLE ?= yes
+BOOTMAGIC_ENABLE = lite
+MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
+CONSOLE_ENABLE = no	# Console for debug(+400)
+COMMAND_ENABLE = no    # Commands for debug and configuration
+SLEEP_LED_ENABLE = no  # Breathing sleep LED during USB suspend
+NKRO_ENABLE = yes		# USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+BACKLIGHT_ENABLE = yes  # Enable keyboard backlight functionality
+AUDIO_ENABLE = no
+RGBLIGHT_ENABLE = yes
-- 
cgit v1.2.3