Added revised and working LED module, including its documentation.

This commit is contained in:
Felix 2013-02-06 17:17:19 +01:00
parent 422cb5b7e5
commit 312ee45006
9 changed files with 719 additions and 562 deletions

View File

@ -32,14 +32,14 @@ out the following webpage: http://wiki.osdev.org/Expanded_Main_Page
If you are looking for more PSP-related resources, you should consider checking out the following links If you are looking for more PSP-related resources, you should consider checking out the following links
below: below:
- [LAN.st - IDStorage][1] - LAN.st - IDStorage: http://lan.st/archive/index.php/t-151.html
- [LAN.st - General PSP questions][2] - LAN.st - General PSP questions: http://lan.st/archive/index.php/t-3013.html
- [LAN.st - PSP Motherboard information][3] - LAN.st - PSP Motherboard information: http://lan.st/archive/index.php/t-372.html
- [Yet Another laystation Portable Documentation][4] - Yet Another laystation Portable Documentation: http://hitmen.c02.at/files/yapspd/psp_doc.pdf.tar.gz
- [PSP Module Tutorial][5] - PSP Module Tutorial: http://pspdev1.com/wp-content/uploads/2007/03/moduletutorialv1.pdf
- [24C3 - TyRaNiD on early PSP hacking + Pandorra hack][6] - 24C3 - TyRaNiD on early PSP hacking + Pandorra hack: https://www.youtube.com/watch?v=INdUZk4NFIA
Other websites are: Other websites are:
- http://wololo.net - http://wololo.net
@ -50,11 +50,5 @@ Contact
------- -------
You can stay in touch with us and discuss project-related topics with us via the following ways: You can stay in touch with us and discuss project-related topics with us via the following ways:
- via IRC on the FreeNode server (irc.freenode.net) (join the channel #uofw). - via IRC on the FreeNode server (irc.freenode.net) (join the channel #uofw)
- via e-mail
[1]: http://lan.st/archive/index.php/t-151.html
[2]: http://lan.st/archive/index.php/t-3013.html
[3]: http://lan.st/archive/index.php/t-372.html
[4]: http://hitmen.c02.at/files/yapspd/psp_doc.pdf.tar.gz
[5]: http://pspdev1.com/wp-content/uploads/2007/03/moduletutorialv1.pdf
[6]: https://www.youtube.com/watch?v=INdUZk4NFIA

View File

@ -1,4 +1,4 @@
/** Copyright (C) 2011, 2012 The uOFW team /** Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission. See the file COPYING for copying permission.
*/ */
@ -12,12 +12,12 @@
#ifndef CTRL_H #ifndef CTRL_H
#define CTRL_H #define CTRL_H
/** The callback function used by ::sceCtrlSetSpecialButtonCallback. */ /** The callback function used by ::sceCtrlSetSpecialButtonCallback(). */
typedef void (*SceKernelButtonCallbackFunction)(u32 curButtons, u32 lastButtons, void *opt); typedef void (*SceKernelButtonCallbackFunction)(u32 curButtons, u32 lastButtons, void *opt);
/** /**
* This structure is for obtaining button data (button/stick information) from the * This structure is for obtaining button data (button/stick information) from the
* controller using ::sceCtrlPeekBufferPositive, ::sceCtrlReadBufferNegative and similar * controller using ::sceCtrlPeekBufferPositive(), ::sceCtrlReadBufferNegative() and similar
* functions. * functions.
*/ */
typedef struct { typedef struct {
@ -38,7 +38,7 @@ typedef struct {
/** /**
* This structure is for obtaining button data (button/stick information) from the * This structure is for obtaining button data (button/stick information) from the
* controller using ::sceCtrlPeekBufferPositiveExtra, ::sceCtrlReadBufferNegativeExtra * controller using ::sceCtrlPeekBufferPositiveExtra(), ::sceCtrlReadBufferNegativeExtra()
* and similar functions. * and similar functions.
*/ */
typedef struct { typedef struct {
@ -75,7 +75,7 @@ typedef struct {
/** /**
* This structure is for obtaining button status values from the controller using * This structure is for obtaining button status values from the controller using
* ::sceCtrlPeekLatch and ::sceCtrlReadLatch. Each structure member contains button * ::sceCtrlPeekLatch() and ::sceCtrlReadLatch(). Each structure member contains button
* values of ::SceCtrlPadButtons. * values of ::SceCtrlPadButtons.
*/ */
typedef struct { typedef struct {
@ -509,8 +509,8 @@ s32 sceCtrlReadBufferPositive(SceCtrlData *data, u8 nBufs);
s32 sceCtrlReadBufferNegative(SceCtrlData *data, u8 nBufs); s32 sceCtrlReadBufferNegative(SceCtrlData *data, u8 nBufs);
/** /**
* Extended ::sceCtrlPeekBufferPositive. See description for more info. * Extended ::sceCtrlPeekBufferPositive(). See description for more info.
* You need to call ::SceCtrlExtendInternalCtrlBuffers before use. * You need to call ::SceCtrlExtendInternalCtrlBuffers() before use.
* *
* @param arg1 Pass 1 or 2. * @param arg1 Pass 1 or 2.
* @param data Pointer to controller data structure in which button information is stored. The obtained * @param data Pointer to controller data structure in which button information is stored. The obtained
@ -523,8 +523,8 @@ s32 sceCtrlReadBufferNegative(SceCtrlData *data, u8 nBufs);
s32 sceCtrlPeekBufferPositiveExtra(s32 arg1, SceCtrlDataExt *data, u8 nBufs); s32 sceCtrlPeekBufferPositiveExtra(s32 arg1, SceCtrlDataExt *data, u8 nBufs);
/** /**
* Extended ::sceCtrlPeekBufferNegative. See description for more info. * Extended ::sceCtrlPeekBufferNegative(). See description for more info.
* You need to call ::sceCtrlExtendInternalCtrlBuffers before use. * You need to call ::sceCtrlExtendInternalCtrlBuffers() before use.
* *
* @param arg1 Unknown. Pass 1 or 2. * @param arg1 Unknown. Pass 1 or 2.
* @param data Pointer to controller data structure in which button information is stored. The obtained * @param data Pointer to controller data structure in which button information is stored. The obtained
@ -537,8 +537,8 @@ s32 sceCtrlPeekBufferPositiveExtra(s32 arg1, SceCtrlDataExt *data, u8 nBufs);
s32 sceCtrlPeekBufferNegativeExtra(s32 arg1, SceCtrlDataExt *data, u8 nBufs); s32 sceCtrlPeekBufferNegativeExtra(s32 arg1, SceCtrlDataExt *data, u8 nBufs);
/** /**
* Extended ::sceCtrlReadBufferPositive. See description for more info. * Extended ::sceCtrlReadBufferPositive(). See description for more info.
* You need to call ::sceCtrlExtendInternalCtrlBuffers before use. * You need to call ::sceCtrlExtendInternalCtrlBuffers() before use.
* *
* @param arg1 Pass 1 or 2. * @param arg1 Pass 1 or 2.
* @param data Pointer to controller data structure in which button information is stored. The obtained * @param data Pointer to controller data structure in which button information is stored. The obtained
@ -551,8 +551,8 @@ s32 sceCtrlPeekBufferNegativeExtra(s32 arg1, SceCtrlDataExt *data, u8 nBufs);
s32 sceCtrlReadBufferPositiveExtra(s32 arg1, SceCtrlDataExt *data, u8 nBufs); s32 sceCtrlReadBufferPositiveExtra(s32 arg1, SceCtrlDataExt *data, u8 nBufs);
/** /**
* Extended ::sceCtrlReadBufferNegative. See description for more info. * Extended ::sceCtrlReadBufferNegative(). See description for more info.
* You need to call ::sceCtrlExtendInternalCtrlBuffers before use. * You need to call ::sceCtrlExtendInternalCtrlBuffers() before use.
* *
* @param arg1 Pass 1 or 2. * @param arg1 Pass 1 or 2.
* @param data Pointer to controller data structure in which button information is stored. The obtained * @param data Pointer to controller data structure in which button information is stored. The obtained

136
include/led.h Normal file
View File

@ -0,0 +1,136 @@
/* Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission.
*/
#ifndef LED_H
#define LED_H
#include "common_header.h"
/** @defgroup LED LED Module
*
* @{
*/
/**
* The LEDs which can be controlled via ::sceLedSetMode().
*/
enum ScePspLedTypes {
/** Memory-Stick LED. */
PSP_LED_TYPE_MS = 0,
/** W-LAN LED. */
PSP_LED_TYPE_WLAN = 1,
/** Bluetooth LED. */
PSP_LED_TYPE_BT = 2
};
/**
* The possible LED control commands.
*/
enum SceLedModes {
/** Turn a LED OFF. */
LED_MODE_OFF = 0,
/** Turn a LED ON. */
LED_MODE_ON = 1,
/** Set a blink event for a LED. */
LED_MODE_BLINK = 2,
/**
* Register LED configuration commands and execute them. Its use is not recommended,
* as it is still not completely known how that mode works.
*/
LED_MODE_SELECTIVE_EXEC = 3
};
/**
* LED control commands which can be passed via a
* ::SceLedConfiguration package to the system.
*/
enum SceLedCmds {
/**
* Save a LED configuration command for later use. You can only
* save one configuration.
*/
LED_CMD_SAVE_CMD = 1,
/** Execute a saved LED configuration command. */
LED_CMD_EXECUTE_SAVED_CMD = 2,
/**
* Register a LED configuration to be executed manually by the user.
* Upto 4 LED configuration can be registered the same time.
*/
LED_CMD_REGISTER_CMD = 3,
/**
* Execute the recently registered LED configuration. Once it has been executed as
* many times the user as the user decided,
*/
LED_CMD_EXECUTE_CMD = 4,
/** Turn ON a specified LED. */
LED_CMD_TURN_LED_ON = 16,
/** Turn OFF a specified LED. */
LED_CMD_TURN_LED_OFF = 17,
/** Switch the state of an LED. ON -> OFF, or OFF -> ON.*/
LED_CMD_SWITCH_LED_STATE = 18,
/**
* Setup a blink event for a LED. The settings for the blink event are set via the
* ::SceLedConfiguration.
*/
LED_CMD_BLINK_LED = 19,
};
/**
* This structure represents a LED blink configuration. It needs to be specified
* when using ::sceLedSetMode and the LED_MODE_BLINK / LED_MODE_SELECTIVE_EXEC
* setting for the LED mode. A blink event contains an ON-/OFF-time for the target
* LED, the total time of the event and the final LED state at the end of the event.
*
* Note: When using LED_MODE_BLINK, you don't need to set the first four structure
* members.
*/
typedef struct {
/** This command should be used to register/execute a custom command. */
u8 selectiveCmd;
/** The number or executions of the specified <customCmd>.*/
u8 numExecs;
/** The custom LED command to execute. One of ::SceLedCmds. */
u8 customCmd;
/** Unknown. */
u8 unk;
/** The "on" time of a LED during a blink period. */
s32 onTime;
/** The "off" time of a LED during a blink period. */
s32 offTime;
/** The time of a blink period. Set to -1 for an infinite time period. */
s32 blinkTime;
/** The state of a LED at the end of the blink period. */
s32 endBlinkState;
} SceLedConfiguration;
/**
* Initialize the LED library, enable the PSP's LEDs and turn them ON.
*
* @return 0.
*/
u32 sceLedInit(void);
/**
* Terminate the LED library and disable the PSP's LEDs.
*
* @return 0.
*/
u32 sceLedEnd(void);
/**
* Set a LED mode.
*
* @param led The LED to set a mode for. One of ::ScePspLedTypes.
* @param mode The mode to set for a LED. One of ::SceLedModes.
* @param config Configuration settings for a LED. Is only used for the ::SceLedModes
* LED_MODE_BLINK and LED_MODE_DELAY.
*
* @return 0 on success.
*/
s32 sceLedSetMode(s32 led, s32 mode, SceLedConfiguration *config);
#endif /* LED_H */
/** @} */

View File

@ -1,9 +1,28 @@
/* Copyright (C) 2011, 2012 The uOFW team /* Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission. See the file COPYING for copying permission.
*/ */
/**
* GPIO Port masks.
*/
enum SceGpioPortMasks {
SCE_GPIO_MASK_LED_MS = 0x40,
SCE_GPIO_MASK_LED_WLAN = 0x80,
SCE_GPIO_MASK_LED_BT = 0x1000000
};
enum SceGpioPortModes {
/** Memory Stick GPIO port mode. */
SCE_GPIO_PORT_MODE_MS = 6,
/** W-LAN GPIO port mode. */
SCE_GPIO_PORT_MODE_WLAN = 7,
/** Bluetooth GPIO port mode. */
SCE_GPIO_PORT_MODE_BT = 24,
};
s32 sceGpioPortSet(s32); s32 sceGpioPortSet(s32);
s32 sceGpioPortClear(s32); s32 sceGpioPortClear(s32);
s32 sceGpioGetPortMode(s32);
s32 sceGpioSetPortMode(s32, s32); s32 sceGpioSetPortMode(s32, s32);
s32 sceGpioDisableTimerCapture(s32, s32); s32 sceGpioDisableTimerCapture(s32, s32);
s32 sceGpioSetIntrMode(s32, s32); s32 sceGpioSetIntrMode(s32, s32);

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2011, 2012 The uOFW team /* Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission. See the file COPYING for copying permission.
*/ */
@ -104,6 +104,21 @@
#define PSP_SYSCON_RX_RESPONSE (2) #define PSP_SYSCON_RX_RESPONSE (2)
#define PSP_SYSCON_RX_DATA(i) (3 + (i)) #define PSP_SYSCON_RX_DATA(i) (3 + (i))
/**
* PSP Hardware LEDs which can be turned ON/OFF
* via ::sceSysconCtrlLED().
*/
enum PspSysconLeds {
/** Memory-Stick LED. */
PSP_SYSCON_LED_MS,
/** W-LAN LED. */
PSP_SYSCON_LED_WLAN,
/** Power LED. */
PSP_SYSCON_LED_POWER,
/** Bluetooth LED.*/
PSP_SYSCON_LED_BT
};
/** A system controller packet, used to run a syscon command. */ /** A system controller packet, used to run a syscon command. */
typedef struct SceSysconPacket { typedef struct SceSysconPacket {
/** Next packet in the list. */ /** Next packet in the list. */
@ -966,7 +981,7 @@ s32 sceSysconCtrlPower(u32 arg0, u32 arg1);
/** /**
* Turn a LED on or off. * Turn a LED on or off.
* *
* @param led The LED id (0, 1, 2 or 3). * @param led The LED id, one of ::PspSysconLeds.
* @param set Set this value to 1 if you want the LED to turn on, or 0 if you want it to turn off. * @param set Set this value to 1 if you want the LED to turn on, or 0 if you want it to turn off.
* *
* @return 0 on success. * @return 0 on success.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2011, 2012 The uOFW team /* Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission. See the file COPYING for copying permission.
*/ */
@ -95,6 +95,27 @@ void *sceKernelMemset32(void *buf, int c, int size);
void *sceKernelMemset(void *buf, int c, u32 size); void *sceKernelMemset(void *buf, int c, u32 size);
int sceKernelGetCompiledSdkVersion(void); int sceKernelGetCompiledSdkVersion(void);
/** PSP Hardware models. */
enum ScePspHwModels {
/** PSP Fat (01g). */
PSP_1000 = 0,
/** PSP Slim (02g). */
PSP_2000 = 1,
/** PSP Brite (03g). */
PSP_3000 = 2,
/** PSP Brite (04g). */
PSP_4000 = 3,
/** PSP Go (05g). */
PSP_GO = 4,
/** PSP Brite (07g). */
PSP_7000 = 6,
/** PSP Brite (09g). */
PSP_9000 = 8,
/** PSP Street E-1000 (11g). */
PSP_11000 = 10,
};
int sceKernelGetModel(void); int sceKernelGetModel(void);
#endif #endif

View File

@ -227,5 +227,7 @@ typedef struct {
int sceKernelReferFplStatus(SceUID uid, SceKernelFplInfo *info); int sceKernelReferFplStatus(SceUID uid, SceKernelFplInfo *info);
s64 sceKernelGetSystemTimeWide(void);
#endif /* THREADMAN_KERNEL_H */ #endif /* THREADMAN_KERNEL_H */

View File

@ -1,10 +1,12 @@
/* Copyright (C) 2011, 2012 The uOFW team /* Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission. See the file COPYING for copying permission.
*/ */
/* /*
* uOFW/trunk/src/ctrl/ctrl.c * uOFW/trunk/src/ctrl/ctrl.c
* *
* sceController_Service - a driver the PSP's hardware buttons.
*
* The controller libraries (controller and controller_driver) main * The controller libraries (controller and controller_driver) main
* function is to notify an application of information that is output * function is to notify an application of information that is output
* from the controller, such as button and analog stick information. * from the controller, such as button and analog stick information.
@ -36,8 +38,8 @@
SCE_MODULE_INFO("sceController_Service", SCE_MODULE_KERNEL | SCE_MODULE_ATTR_CANT_STOP | SCE_MODULE_ATTR_EXCLUSIVE_LOAD | SCE_MODULE_INFO("sceController_Service", SCE_MODULE_KERNEL | SCE_MODULE_ATTR_CANT_STOP | SCE_MODULE_ATTR_EXCLUSIVE_LOAD |
SCE_MODULE_ATTR_EXCLUSIVE_START, 1, 1); SCE_MODULE_ATTR_EXCLUSIVE_START, 1, 1);
SCE_MODULE_BOOTSTART("CtrlInit"); SCE_MODULE_BOOTSTART("_sceCtrlModuleStart");
SCE_MODULE_REBOOT_BEFORE("CtrlRebootBefore"); SCE_MODULE_REBOOT_BEFORE("_sceCtrlModuleRebootBefore");
SCE_SDK_VERSION(SDK_VERSION); SCE_SDK_VERSION(SDK_VERSION);
#define USER_MODE (0) #define USER_MODE (0)
@ -2098,13 +2100,13 @@ static s32 _sceCtrlReadBuf(SceCtrlDataExt *data, u8 nBufs, s32 arg3, u8 mode)
return numReadIntBufs; return numReadIntBufs;
} }
s32 CtrlInit(void) s32 _sceCtrlModuleStart(s32 argc __attribute__((unused)), void *argp __attribute__((unused)))
{ {
sceCtrlInit(); sceCtrlInit();
return SCE_ERROR_OK; return SCE_ERROR_OK;
} }
s32 CtrlRebootBefore(void) s32 _sceCtrlModuleRebootBefore(s32 argc __attribute__((unused)), void *argp __attribute__((unused)))
{ {
sceCtrlEnd(); sceCtrlEnd();
return SCE_ERROR_OK; return SCE_ERROR_OK;

File diff suppressed because it is too large Load Diff