Skip to content

Commit d1bd751

Browse files
committed
added header comments so it's easy to figure out where a method is defined in a specific header
1 parent ca38323 commit d1bd751

File tree

9 files changed

+140
-80
lines changed

9 files changed

+140
-80
lines changed

platform/m6/kbd.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@
55
#include "kbd_common.h"
66
#include "levent.h"
77

8+
KeyMap keymap[] = {
9+
{ 0, KEY_PLAYBACK, 0x00000002 }, // Found @0xe05e4cdc, levent 0x101 (uses inverted logic in physw_status)
10+
{ 0, KEY_WIFI, 0x00000004 }, // Found @0xe05e4ce4, levent 0x103 (uses inverted logic in physw_status)
11+
{ 1, KEY_MENU, 0x00000080 }, // Found @0xe05e4d1c, levent 0x15
12+
{ 1, KEY_UP, 0x00000100 }, // Found @0xe05e4d24, levent 0x06
13+
{ 1, KEY_DOWN, 0x00000200 }, // Found @0xe05e4d2c, levent 0x07
14+
{ 1, KEY_RIGHT, 0x00000400 }, // Found @0xe05e4d34, levent 0x09
15+
{ 1, KEY_LEFT, 0x00000800 }, // Found @0xe05e4d3c, levent 0x08
16+
{ 1, KEY_SET, 0x00001000 }, // Found @0xe05e4d44, levent 0x0a
17+
{ 1, KEY_ERASE, 0x00008000 }, // Found @0xe05e4d5c, levent 0x0b
18+
{ 2, KEY_VIDEO, 0x00002000 }, // Found @0xe05e4db4, levent 0x02
19+
{ 0, 0, 0 }
20+
};
21+
22+
/**
23+
* @header usb_remote.h
24+
*/
825
int get_usb_bit() {
926
long usb_physw[3];
1027
usb_physw[USB_IDX] = 0;
1128
_kbd_read_keys_r2(usb_physw);
1229
return ((usb_physw[USB_IDX] & USB_MASK) == USB_MASK);
1330
}
14-
15-
KeyMap keymap[] = {
16-
{ 0, KEY_PLAYBACK ,0x00000002 }, // Found @0xe05e4cdc, levent 0x101 (uses inverted logic in physw_status)
17-
{ 0, KEY_WIFI ,0x00000004 }, // Found @0xe05e4ce4, levent 0x103 (uses inverted logic in physw_status)
18-
{ 1, KEY_MENU ,0x00000080 }, // Found @0xe05e4d1c, levent 0x15
19-
{ 1, KEY_UP ,0x00000100 }, // Found @0xe05e4d24, levent 0x06
20-
{ 1, KEY_DOWN ,0x00000200 }, // Found @0xe05e4d2c, levent 0x07
21-
{ 1, KEY_RIGHT ,0x00000400 }, // Found @0xe05e4d34, levent 0x09
22-
{ 1, KEY_LEFT ,0x00000800 }, // Found @0xe05e4d3c, levent 0x08
23-
{ 1, KEY_SET ,0x00001000 }, // Found @0xe05e4d44, levent 0x0a
24-
{ 1, KEY_ERASE ,0x00008000 }, // Found @0xe05e4d5c, levent 0x0b
25-
{ 2, KEY_VIDEO ,0x00002000 }, // Found @0xe05e4db4, levent 0x02
26-
{ 0, 0, 0 }
27-
};

platform/m6/lib.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,47 @@
44

55
#define LED_PR 0xd20b0994 // green LED on the back
66

7+
void shutdown_soft() {
8+
_PostLogicalEventForNotPowerType(0x1005, 0);
9+
}
10+
11+
/**
12+
* @see main startup
13+
*/
714
void shutdown() {
815
while (1)
916
_SleepTask(500);
1017
}
1118

19+
/**
20+
* @header debug_led.h
21+
*/
1222
void debug_led(int state) {
1323
volatile long *p = (void*) LED_PR;
1424
*p = ((state) ? 0x4d0002 : 0x4c0003);
1525
}
1626

17-
// Power Led = first entry in table (led 0)
18-
// AF Assist Lamp = second entry in table (led 1)
27+
/**
28+
* Power Led = first entry in table (led 0).
29+
* AF Assist Lamp = second entry in table (led 1).
30+
*
31+
* @header debug_led.h
32+
*/
1933
void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
2034
static char led_table[2] = { 0, 4 };
2135
_LEDDrive(led_table[led % sizeof(led_table)], state <= 1 ? !state : state);
2236
}
2337

24-
void shutdown_soft() {
25-
_PostLogicalEventForNotPowerType(0x1005, 0);
26-
}
27-
38+
/**
39+
* @header keyboard.h
40+
*/
2841
void JogDial_CW(void) {
2942
_PostLogicalEventToUI(0x872, 1); // RotateJogDialRight
3043
}
3144

45+
/**
46+
* @header keyboard.h
47+
*/
3248
void JogDial_CCW(void) {
3349
_PostLogicalEventToUI(0x873, 1); // RotateJogDialLeft
3450
}

platform/m6/main.c

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,54 @@ extern long link_bss_end;
88
extern void boot();
99

1010
void startup() {
11-
long *bss = &link_bss_start;
12-
// sanity check
13-
if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)) {
14-
started();
15-
shutdown();
16-
}
17-
// initialize .bss senment
18-
while (bss<&link_bss_end)
19-
*bss++ = 0;
20-
boot();
11+
long *bss = &link_bss_start;
12+
// sanity check
13+
if ((long) &link_bss_end > (MEMISOSTART + MEMISOSIZE)) {
14+
started();
15+
shutdown();
16+
}
17+
// initialize .bss senment
18+
while (bss < &link_bss_end)
19+
*bss++ = 0;
20+
boot();
2121
}
2222

2323
const int zoom_points = 1;
2424
extern int _GetLensCurrentFocalLength(void);
2525
extern int _GetLensWideFocalLength(void);
2626

27+
/**
28+
* @header shooting.h
29+
*/
2730
int get_effective_focal_length(__attribute__ ((unused))int zp) {
28-
return _GetLensCurrentFocalLength() * 1600;
31+
return _GetLensCurrentFocalLength() * 1600;
2932
}
3033

34+
/**
35+
* @header shooting.h
36+
*/
3137
int get_focal_length(__attribute__ ((unused))int zp) {
32-
return _GetLensCurrentFocalLength() * 1000;
38+
return _GetLensCurrentFocalLength() * 1000;
3339
}
3440

41+
/**
42+
* @header shooting.h
43+
*/
3544
int get_zoom_x(__attribute__ ((unused))int zp) {
36-
return _GetLensCurrentFocalLength()*100 / (_GetLensWideFocalLength()*100);
45+
// TODO: why the 100 ?
46+
return _GetLensCurrentFocalLength() * 100/ (_GetLensWideFocalLength() * 100);
3747
}
3848

39-
long get_vbatt_min()
40-
{
41-
return 2*3300;
49+
/**
50+
* @header battery.h
51+
*/
52+
long get_vbatt_min() {
53+
return 2 * 3300;
4254
}
4355

44-
45-
long get_vbatt_max()
46-
{
47-
return 2*4168; // 4168 original battery just charged ASM1989
56+
/**
57+
* @header battery.h
58+
*/
59+
long get_vbatt_max() {
60+
return 2 * 4168; // 4168 original battery just charged ASM1989
4861
}

platform/m6/notes.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
--- EOS M6 ---
2-
1+
---- EOS M6 ----
32
processor: DIGIC 7 (Cortex A9)
43
architecture: ARMv7-a
54
sensor: 22.3mm x 14.9mm CMOS
65
aspect ratio: 3:2
76
image size: 6000 x 4000
87
raw: 14 bit
98
iso: 100-25600
10-
interface: micro USB, WiFi, NFC, Bluetooth
9+
interface: micro USB, WiFi, Bluetooth
1110
port: micro HDMI, 3.5mm stereo jack
1211
battery: LP-E17

platform/m6/platform_camera.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
// Camera - M6 - platform_camera.h
2-
3-
// This file contains the various settings values specific to the EOS M6 camera.
4-
// This file is referenced via the 'include/camera.h' file and should not be loaded directly.
5-
6-
// If adding a new settings value put a suitable default in 'include/camera.h',
7-
// along with documentation on what the setting does and how to determine the correct value.
8-
// If the setting should not have a default value then add it in 'include/camera.h'
9-
// using the '#undef' directive along with appropriate documentation.
10-
11-
// Override any default values with your camera specific values in this file. Try and avoid
12-
// having override values that are the same as the default value.
13-
14-
// When overriding a setting value there are two cases:
15-
// 1. If removing the value, because it does not apply to your camera, use the '#undef' directive.
16-
// 2. If changing the value it is best to use an '#undef' directive to remove the default value
17-
// followed by a '#define' to set the new value.
18-
19-
// When porting CHDK to a new camera, check the documentation in 'include/camera.h'
20-
// for information on each setting. If the default values are correct for your camera then
21-
// don't override them again in here.
1+
/**
2+
* Camera - M6 - platform_camera.h
3+
*
4+
* This file contains the various settings values specific to the EOS M6 camera.
5+
* This file is referenced via the 'include/camera.h' file and should not be loaded directly.
6+
*
7+
* If adding a new settings value put a suitable default in 'include/camera.h',
8+
* along with documentation on what the setting does and how to determine the correct value.
9+
* If the setting should not have a default value then add it in 'include/camera.h'
10+
* using the '#undef' directive along with appropriate documentation.
11+
*
12+
* Override any default values with your camera specific values in this file. Try and avoid
13+
* having override values that are the same as the default value.
14+
*
15+
* When overriding a setting value there are two cases:
16+
* 1. If removing the value, because it does not apply to your camera, use the '#undef' directive.
17+
* 2. If changing the value it is best to use an '#undef' directive to remove the default value
18+
* followed by a '#define' to set the new value.
19+
*
20+
* When porting CHDK to a new camera, check the documentation in 'include/camera.h'
21+
* for information on each setting. If the default values are correct for your camera then
22+
* don't override them again in here.
23+
*/
2224

2325
// from signature finder
2426
#define CAM_DRYOS 1
@@ -51,5 +53,6 @@
5153
#define CAM_HAS_VIDEO_BUTTON 1
5254
#undef CAM_HAS_ERASE_BUTTON
5355

54-
#define CAM_3ARG_DebugAssert 1 // from Ghidra
56+
#define CAM_3ARG_DebugAssert 1 // confirmed with Ghidra
5557
#define CAM_FILE_COUNTER_IS_VAR 1
58+
#define CAM_DATE_FOLDER_NAMING 0x80

platform/m6/platform_kbd.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#ifndef PLATFORM_KBD_H
22
#define PLATFORM_KBD_H
33

4-
// plaform specific keyboard defines, see core/kbd_common.c for documentation
5-
// non-standard key state update to handle inverted keys, etc
4+
/**
5+
* Platform specific keyboard defines, see core/kbd_common.c for documentation
6+
* non-standard key state update to handle inverted keys, etc
7+
*/
68

79
// from signature finder
810
#define SD_READONLY_FLAG 0x00000020 // Found @0xe05e4d0c, levent 0x30a

platform/m6/shooting.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const ISOTable iso_table[] = {
113113
{ 25, 25600, "25600", -1},
114114
};
115115

116+
// TODO: map the rest
116117
const CapturemodeMap modemap[] = {
117118
{ MODE_M, 32770 }, //
118119
{ MODE_AV, 32771 }, //
@@ -122,26 +123,28 @@ const CapturemodeMap modemap[] = {
122123

123124
#include "../generic/shooting.c"
124125

126+
/**
127+
* @header file_counter.h
128+
*/
125129
long get_file_next_counter() {
126130
return get_file_counter();
127131
}
128132

133+
/**
134+
* @header file_counter.h
135+
*/
129136
long get_target_file_num() {
130137
return get_exposure_counter();
131138
}
132139

133-
#if defined(CAM_DATE_FOLDER_NAMING) // TODO: not really sure why there is a if/else ?
140+
/**
141+
* @header file_counter.h
142+
*/
134143
void get_target_dir_name(char *out) {
135144
if (!out) {
136145
return;
137146
}
138147
extern void _GetImageFolder(char*, int, int, int);
139148
_GetImageFolder(out, get_file_next_counter(), CAM_DATE_FOLDER_NAMING, time(NULL));
140149
}
141-
#else
142-
long get_target_dir_num()
143-
{
144-
return 0;
145-
}
146-
#endif
147150

platform/m6/sub/101a/boot.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* @see main startup
3+
*/
14
void __attribute__((naked,noinline)) boot() {
25

36
}

platform/m6/wrappers.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
#include "../generic/wrappers.c"
22

3+
/**
4+
* @header lens.h
5+
*/
36
long lens_get_focus_pos() {
47
return _GetFocusLensSubjectDistance();
58
}
69

10+
/**
11+
* @header lens.h
12+
*/
713
long lens_get_focus_pos_from_lens() {
814
return _GetFocusLensSubjectDistanceFromLens();
915
}
1016

17+
/**
18+
* @header lens.h
19+
*/
1120
long lens_get_target_distance() {
1221
return _GetCurrentTargetDistance();
1322
}
1423

15-
int _EngDrvRead(int gpio_reg) {
16-
extern int _EngDrvRead_FW(int*);
17-
return _EngDrvRead_FW(&gpio_reg);
18-
}
19-
20-
// DoMFLock: use _MFOn/_MFOff or _PT_MFOn/_PT_MFOff or _SS_MFOn/_SS_MFOff if defined in stubs_entry.S
24+
/**
25+
* @header lens.h
26+
* @use _MFOn/_MFOff or _PT_MFOn/_PT_MFOff or _SS_MFOn/_SS_MFOff if defined in stubs_entry.S
27+
*/
2128
int DoMFLock(void) {
2229
if (!camera_info.state.mode_play) {
2330
_PT_MFOn();
@@ -26,10 +33,21 @@ int DoMFLock(void) {
2633
return (0);
2734
}
2835

36+
/**
37+
* @header lens.h
38+
*/
2939
int UnlockMF(void) {
3040
if (!camera_info.state.mode_play) {
3141
_PT_MFOff();
3242
return (1);
3343
}
3444
return (0);
3545
}
46+
47+
/**
48+
* @header lolevel.h
49+
*/
50+
int _EngDrvRead(int gpio_reg) {
51+
extern int _EngDrvRead_FW(int*);
52+
return _EngDrvRead_FW(&gpio_reg);
53+
}

0 commit comments

Comments
 (0)