mirror of
https://github.com/rvtr/twl_wrapsdk.git
synced 2025-10-31 06:11:10 -04:00
add micro control unit headers and sample
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@260 4ee2a332-4b2b-5046-8439-1ba90f034370
This commit is contained in:
parent
516a867c68
commit
12f464c9d2
@ -53,7 +53,7 @@ static const u8 deviceAddrTable[I2C_SLAVE_NUM] = {
|
||||
0, // CAMERA_MICRON_OUT
|
||||
0, // CAMERA_SHARP_IN
|
||||
0, // CAMERA_SHARP_OUT
|
||||
0x90, // MICRO_CONTROLLER
|
||||
0x98, // MICRO_CONTROLLER
|
||||
0, // DEBUG_LED
|
||||
};
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@ SUBDIRS += \
|
||||
dsp \
|
||||
spi \
|
||||
el \
|
||||
mcu \
|
||||
|
||||
endif # TWL_PLATFORM != DSTEG
|
||||
|
||||
|
||||
30
build/tests/mcu/Makefile
Normal file
30
build/tests/mcu/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - tests - mcu
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Log: $
|
||||
# $NoKeywords: $
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS = mcu-1 \
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
|
||||
#===== End of Makefile =====
|
||||
44
build/tests/mcu/mcu-1/ARM7/Makefile
Normal file
44
build/tests/mcu/mcu-1/ARM7/Makefile
Normal file
@ -0,0 +1,44 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - MC - demos - mc-1
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Log: $
|
||||
# $NoKeywords: $
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS =
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
#TWL_CODEGEN = THUMB
|
||||
TWL_PROC = ARM7
|
||||
|
||||
TARGET_BIN = main.axf
|
||||
|
||||
SRCS = main.c
|
||||
|
||||
#SRCDIR = # using default
|
||||
#LCFILE = # using default
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
do-build: $(TARGETS)
|
||||
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
|
||||
#===== End of Makefile =====
|
||||
210
build/tests/mcu/mcu-1/ARM7/src/main.c
Normal file
210
build/tests/mcu/mcu-1/ARM7/src/main.c
Normal file
@ -0,0 +1,210 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - MCU - demos - mcu-1
|
||||
File: main.c
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Log: main.c,v $
|
||||
$NoKeywords: $
|
||||
*---------------------------------------------------------------------------*/
|
||||
#include <twl.h>
|
||||
|
||||
//================================================================================
|
||||
static void dump(const char *str, void *ptr, u32 length)
|
||||
{
|
||||
u8 *rdata = (u8*)ptr;
|
||||
int i;
|
||||
OS_TPrintf("\n[%s] (%d bytes):\n\t", str, length);
|
||||
for (i = 0; i < length; i++) {
|
||||
OS_TPrintf("%02X", *rdata++);
|
||||
if ((i & 0xF) == 0xF) OS_TPrintf("\n\t");
|
||||
else OS_TPrintf(" ");
|
||||
}
|
||||
OS_TPrintf("\n");
|
||||
}
|
||||
|
||||
extern s32 I2CSlowRateTable[];
|
||||
|
||||
static void test_normal(void)
|
||||
{
|
||||
OS_TPrintf("\n\n[%s]\n\n", __func__);
|
||||
|
||||
OS_TPrintf("MCU_IsResetRequest: %s\n", MCU_IsResetRequest() ? "TRUE" : "FALSE");
|
||||
OS_TPrintf("\n");
|
||||
|
||||
OS_TPrintf("MCU_IsWifi : %s\n", MCU_IsWifi() ? "TRUE" : "FALSE");
|
||||
OS_TPrintf("MCU_SetWifi(TRUE) : %s\n", MCU_SetWifi(TRUE) ? "SUCCESS" : "FAILED");
|
||||
OS_TPrintf("MCU_IsWifi : %s\n", MCU_IsWifi() ? "TRUE" : "FALSE");
|
||||
SVC_WaitByLoop(0x100000);
|
||||
OS_TPrintf("MCU_SetWifi(FALSE): %s\n", MCU_SetWifi(FALSE) ? "SUCCESS" : "FAILED");
|
||||
OS_TPrintf("MCU_IsWifi : %s\n", MCU_IsWifi() ? "TRUE" : "FALSE");
|
||||
OS_TPrintf("\n");
|
||||
|
||||
OS_TPrintf("MCU_GetCameraPattern : %s\n", MCU_GetCameraPattern() ? "Blink" : "None");
|
||||
OS_TPrintf("MCU_SetCameraPattern(MCU_CAMERA_PATTERN_BLINK): %s\n", MCU_SetCameraPattern(MCU_CAMERA_PATTERN_BLINK) ? "SUCCESS" : "FAILED");
|
||||
OS_TPrintf("MCU_GetCameraPattern : %s\n", MCU_GetCameraPattern() ? "Blink" : "None");
|
||||
OS_TPrintf("MCU_SetCameraPattern(MCU_CAMERA_PATTERN_NONE) : %s\n", MCU_SetCameraPattern(MCU_CAMERA_PATTERN_NONE) ? "SUCCESS" : "FAILED");
|
||||
OS_TPrintf("MCU_GetCameraPattern : %s\n", MCU_GetCameraPattern() ? "Blink" : "None");
|
||||
OS_TPrintf("\n");
|
||||
|
||||
OS_TPrintf("MCU_GetVolume : %d\n", MCU_GetVolume());
|
||||
OS_TPrintf("MCU_SetVolume(15): %s\n", MCU_SetVolume(15) ? "SUCCESS" : "FAILED");
|
||||
OS_TPrintf("MCU_GetVolume : %d\n", MCU_GetVolume());
|
||||
OS_TPrintf("MCU_SetVolume(31): %s\n", MCU_SetVolume(31) ? "SUCCESS" : "FAILED");
|
||||
OS_TPrintf("MCU_GetVolume : %d\n", MCU_GetVolume());
|
||||
OS_TPrintf("\n");
|
||||
|
||||
OS_TPrintf("MCU_GetVersion : %d\n", MCU_GetVersion());
|
||||
OS_TPrintf("MCU_GetRevision: %d\n", MCU_GetRevision());
|
||||
OS_TPrintf("\n");
|
||||
}
|
||||
|
||||
static void test_tuning(void)
|
||||
{
|
||||
u8 rdata[10];
|
||||
u8 wdata[10];
|
||||
s32 *pInterval = &I2CSlowRateTable[I2C_SLAVE_MICRO_CONTROLLER];
|
||||
const u8 offset = 0x0;
|
||||
const u32 nums = sizeof(rdata);
|
||||
const int times = 200;
|
||||
s32 max = 0;
|
||||
int i, j, k;
|
||||
|
||||
OS_TPrintf("\n\n[%s]\n\n", __func__);
|
||||
|
||||
for (j = 0; j < nums; j++)
|
||||
{
|
||||
rdata[j] = 0;
|
||||
wdata[j] = (u8)(nums + j);
|
||||
}
|
||||
|
||||
// rough tuning
|
||||
for (i = 6; i < 30; i++)
|
||||
{
|
||||
*pInterval = 1 << i;
|
||||
SVC_WaitByLoop(0x200);
|
||||
|
||||
for (j = 0; j < nums; j++)
|
||||
{
|
||||
wdata[j]++;
|
||||
}
|
||||
|
||||
if (MCU_GetFreeRegisters(offset, wdata, nums) && MCU_SetFreeRegisters(offset, rdata, nums))
|
||||
{
|
||||
for (j = 0; j < nums; j++)
|
||||
{
|
||||
if (wdata[j] != rdata[j])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == nums)
|
||||
{
|
||||
OS_TPrintf("Success: 0x%X (%d)\n", *pInterval, *pInterval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fine tuning
|
||||
for (k = 0; k < times; k++)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
(*pInterval)--;
|
||||
|
||||
for (j = 0; j < nums; j++)
|
||||
{
|
||||
wdata[j]++;
|
||||
}
|
||||
|
||||
if (!MCU_GetFreeRegisters(offset, wdata, nums) || !MCU_SetFreeRegisters(offset, rdata, nums))
|
||||
{
|
||||
break;
|
||||
}
|
||||
for (j = 0; j < nums; j++)
|
||||
{
|
||||
if (wdata[j] != rdata[j])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j != nums)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
OS_TPrintf("Failed: 0x%X (%d), ", *pInterval, *pInterval);
|
||||
SVC_WaitByLoop(0x100);
|
||||
|
||||
while (1)
|
||||
{
|
||||
(*pInterval)++;
|
||||
|
||||
for (j = 0; j < nums; j++)
|
||||
{
|
||||
wdata[j] = (u8)(nums + j + k);
|
||||
}
|
||||
|
||||
if (MCU_GetFreeRegisters(offset, wdata, nums) && MCU_SetFreeRegisters(offset, rdata, nums))
|
||||
{
|
||||
for (j = 0; j < nums; j++)
|
||||
{
|
||||
if (wdata[j] != rdata[j])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == nums)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
OS_TPrintf("Success: 0x%X (%d)\n", *pInterval, *pInterval);
|
||||
if (max < *pInterval)
|
||||
{
|
||||
max = *pInterval;
|
||||
}
|
||||
}
|
||||
*pInterval = max;
|
||||
{
|
||||
OSTick begin;
|
||||
OS_InitTick();
|
||||
OS_TPrintf("\n\nResult: interval = 0x%08X (%d) ", max, max);
|
||||
begin = OS_GetTick();
|
||||
SVC_WaitByLoop(max);
|
||||
OS_TPrintf("== %d usec\n", (int)OS_TicksToMicroSeconds(OS_GetTick()-begin));
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: TwlMain
|
||||
|
||||
Description: main
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
void TwlMain()
|
||||
{
|
||||
OS_Init();
|
||||
|
||||
OS_Printf("ARM7 starts.\n");
|
||||
|
||||
test_normal();
|
||||
|
||||
// tune I2C interval
|
||||
//test_tuning();
|
||||
|
||||
// done
|
||||
OS_TPrintf("\nARM7 ends.\n");
|
||||
OS_Terminate();
|
||||
}
|
||||
43
build/tests/mcu/mcu-1/ARM9/Makefile
Normal file
43
build/tests/mcu/mcu-1/ARM9/Makefile
Normal file
@ -0,0 +1,43 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - MCU - demos - mcu-1
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Log: $
|
||||
# $NoKeywords: $
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS =
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
#TWL_CODEGEN = THUMB
|
||||
|
||||
TARGET_BIN = main.axf
|
||||
|
||||
SRCS = main.c
|
||||
|
||||
#SRCDIR = # using default
|
||||
#LCFILE = # using default
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
do-build: $(TARGETS)
|
||||
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
|
||||
#===== End of Makefile =====
|
||||
52
build/tests/mcu/mcu-1/ARM9/src/main.c
Normal file
52
build/tests/mcu/mcu-1/ARM9/src/main.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - MC - demos - mc-1
|
||||
File: main.c
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Log: main.c,v $
|
||||
$NoKeywords: $
|
||||
*---------------------------------------------------------------------------*/
|
||||
#include <twl.h>
|
||||
|
||||
//================================================================================
|
||||
static void dump(const char *str, void *ptr, u32 length)
|
||||
{
|
||||
u8 *data = (u8*)ptr;
|
||||
int i;
|
||||
OS_TPrintf("\n[%s] (%d bytes):\n\t", str, length);
|
||||
for (i = 0; i < length; i++) {
|
||||
OS_TPrintf("%02X", *data++);
|
||||
if ((i & 0xF) == 0xF) OS_TPrintf("\n\t");
|
||||
else OS_TPrintf(" ");
|
||||
}
|
||||
OS_TPrintf("\n");
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: TwlMain
|
||||
|
||||
Description: main
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
void TwlMain()
|
||||
{
|
||||
OS_Init();
|
||||
|
||||
OS_Printf("ARM9 starts.\n");
|
||||
|
||||
CAMERA_Init();
|
||||
|
||||
// done
|
||||
OS_TPrintf("\nARM9 ends.\n");
|
||||
OS_Terminate();
|
||||
}
|
||||
32
build/tests/mcu/mcu-1/Makefile
Normal file
32
build/tests/mcu/mcu-1/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - build
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Log: $
|
||||
# $NoKeywords: $
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS = \
|
||||
ARM7 \
|
||||
ARM9 \
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
|
||||
#===== End of Makefile =====
|
||||
@ -18,7 +18,7 @@
|
||||
#define TWL_MCU_H_
|
||||
|
||||
#ifdef SDK_ARM7
|
||||
#include <twl/mcu/ARM7/i2c.h>
|
||||
#include <twl/mcu/ARM7/mcu.h>
|
||||
#endif
|
||||
|
||||
/* TWL_MCU_H_ */
|
||||
|
||||
276
include/twl/mcu/ARM7/mcu.h
Normal file
276
include/twl/mcu/ARM7/mcu.h
Normal file
@ -0,0 +1,276 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - libraries - mcu
|
||||
File: i2c.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Log: $
|
||||
$NoKeywords: $
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef TWL_MCU_ARM7_MCU_H_
|
||||
#define TWL_MCU_ARM7_MCU_H_
|
||||
|
||||
#include <twl/types.h>
|
||||
#include <twl/mcu/ARM7/i2c.h>
|
||||
#include <twl/mcu/ARM7/mcu_reg.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MCU_SYSTEMMODE_NITRO = 0,
|
||||
MCU_SYSTEMMODE_TWL = 1
|
||||
}
|
||||
MCUSystemMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MCU_CAMERA_PATTERN_NONE = 0,
|
||||
MCU_CAMERA_PATTERN_BLINK = 1
|
||||
}
|
||||
MCUCameraPattern;
|
||||
|
||||
#define MCU_CAMLED_BLINK 1
|
||||
|
||||
#ifdef _cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_IsResetRequest
|
||||
|
||||
Description: get reset button state
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: TRUE if pressed
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_IsResetRequest( void )
|
||||
{
|
||||
u8 data;
|
||||
if ( MCU_ReadRegisters( MCU_REG_IRQ_ADDR, &data, 1 ) )
|
||||
{
|
||||
return (data & MCU_REG_IRQ_RESET_MASK) >> MCU_REG_IRQ_RESET_SHIFT;
|
||||
}
|
||||
return FALSE; // error
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_CacselReset
|
||||
|
||||
Description: cancel reset state
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: TRUE if success
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_CancelReset( void )
|
||||
{
|
||||
return MCU_ClearFlags( MCU_REG_IRQ_ADDR, MCU_REG_IRQ_RESET_MASK );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_GoDsMode
|
||||
|
||||
Description: set system mode to MCU_SYSTEMMODE_NITRO in MCU.
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: TRUE if success
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_GoDsMode( void )
|
||||
{
|
||||
return MCU_SetParams( MCU_REG_MODE_ADDR, ( MCU_SYSTEMMODE_NITRO << MCU_REG_MODE_SYSTEM_SHIFT ), MCU_REG_MODE_SYSTEM_MASK );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_IsWifi
|
||||
|
||||
Description: get wifi LED status
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: TRUE is on
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_IsWifi( void )
|
||||
{
|
||||
u8 data;
|
||||
if ( MCU_ReadRegisters( MCU_REG_WIFI_ADDR, &data, 1 ) )
|
||||
{
|
||||
return ( data & MCU_REG_WIFI_MASK ) >> MCU_REG_WIFI_SHIFT;
|
||||
}
|
||||
return FALSE; // error
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_SetWifiLed
|
||||
|
||||
Description: set wifi LED status
|
||||
|
||||
Arguments: enabled TRUE if enabled
|
||||
|
||||
Returns: TRUE if success
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_SetWifi( BOOL enabled )
|
||||
{
|
||||
return MCU_SetParams( MCU_REG_WIFI_ADDR, (u8)( enabled ? MCU_REG_WIFI_MASK : 0 ), MCU_REG_WIFI_MASK );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_GetCameraPattern
|
||||
|
||||
Description: get camera LED status.
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: camera LED pattern
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline MCUCameraPattern MCU_GetCameraPattern( void )
|
||||
{
|
||||
u8 data;
|
||||
if ( MCU_ReadRegisters( MCU_REG_CAMERA_ADDR, &data, 1 ) )
|
||||
{
|
||||
return (MCUCameraPattern)( ( data & MCU_REG_CAMERA_PATTERN_MASK ) >> MCU_REG_CAMERA_PATTERN_SHIFT );
|
||||
}
|
||||
return MCU_CAMERA_PATTERN_NONE; // error
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_SetCameraPattern
|
||||
|
||||
Description: set camera LED status.
|
||||
|
||||
Arguments: pattern one of camera LED pattern
|
||||
|
||||
Returns: TRUE if sucess
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_SetCameraPattern( MCUCameraPattern pattern )
|
||||
{
|
||||
return MCU_SetParams( MCU_REG_CAMERA_ADDR, (u8)( pattern << MCU_REG_CAMERA_PATTERN_SHIFT ), MCU_REG_CAMERA_PATTERN_MASK );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_GetVolume
|
||||
|
||||
Description: get current volume.
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: 0xFF if error, otherwise volume (0-31)
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline u8 MCU_GetVolume( void )
|
||||
{
|
||||
u8 data;
|
||||
if ( MCU_ReadRegisters( MCU_REG_VOLUME_ADDR, &data, 1 ) )
|
||||
{
|
||||
return (u8)( ( data & MCU_REG_VOLUME_MASK ) >> MCU_REG_VOLUME_SHIFT );
|
||||
}
|
||||
return 0xFF; // error
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_SetVolume
|
||||
|
||||
Description: set current volume.
|
||||
|
||||
Arguments: volume volume (0-31)
|
||||
|
||||
Returns: TRUE if success
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_SetVolume( u8 volume )
|
||||
{
|
||||
if ( ( volume & ~31 ) == 0 )
|
||||
{
|
||||
return MCU_SetParams( MCU_REG_VOLUME_ADDR, (u8)( volume << MCU_REG_VOLUME_SHIFT ), MCU_REG_VOLUME_MASK );
|
||||
}
|
||||
return FALSE; // invalid parameters
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_GetVersion
|
||||
|
||||
Description: get version.
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: 0xFF if error, otherwise version (0-3)
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline u8 MCU_GetVersion( void )
|
||||
{
|
||||
u8 data;
|
||||
if ( MCU_ReadRegisters( MCU_REG_INFO_ADDR, &data, 1 ) )
|
||||
{
|
||||
return (u8)( ( data & MCU_REG_INFO_VERSION_MASK ) >> MCU_REG_INFO_VERSION_SHIFT );
|
||||
}
|
||||
return 0xFF; // error
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_GetRevision
|
||||
|
||||
Description: get revision.
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: 0xFF if error, otherwise revision (0-3)
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline u8 MCU_GetRevision( void )
|
||||
{
|
||||
u8 data;
|
||||
if ( MCU_ReadRegisters( MCU_REG_INFO_ADDR, &data, 1 ) )
|
||||
{
|
||||
return (u8)( ( data & MCU_REG_INFO_REVISION_MASK ) >> MCU_REG_INFO_REVISION_SHIFT );
|
||||
}
|
||||
return 0xFF; // error
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_GetFreeRegisters
|
||||
|
||||
Description: get free registers.
|
||||
|
||||
Arguments: offset offset bytes (0-15)
|
||||
bufp buffer to store data
|
||||
nums number of bytes to read
|
||||
|
||||
Returns: TRUE if success
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_GetFreeRegisters( u8 offset, u8 *bufp, u32 nums )
|
||||
{
|
||||
if ( ( ( offset + nums - 1 ) & ~15 ) == 0 )
|
||||
{
|
||||
return MCU_ReadRegisters( (u8)( MCU_REG_TEMP_ADDR + offset ), bufp, nums );
|
||||
}
|
||||
return FALSE; // invalid parameters
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MCU_SetFreeRegisters
|
||||
|
||||
Description: set free registers.
|
||||
|
||||
Arguments: offset offset bytes (0-15)
|
||||
bufp buffer to store data
|
||||
nums number of bytes to write (16-1)
|
||||
|
||||
Returns: TRUE if success
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline BOOL MCU_SetFreeRegisters( u8 offset, const u8 *bufp, u32 nums )
|
||||
{
|
||||
if ( ( ( offset + nums - 1 ) & ~15 ) == 0 )
|
||||
{
|
||||
return MCU_WriteRegisters( (u8)( MCU_REG_TEMP_ADDR + offset ), bufp, nums );
|
||||
}
|
||||
return FALSE; // invalid parameters
|
||||
}
|
||||
|
||||
#ifdef _cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
/* TWL_MCU_ARM7_MCU_H_ */
|
||||
#endif
|
||||
73
include/twl/mcu/ARM7/mcu_reg.h
Normal file
73
include/twl/mcu/ARM7/mcu_reg.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - libraries - mcu
|
||||
File: mcu_reg.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Log: $
|
||||
$NoKeywords: $
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef TWL_MCU_ARM7_MCU_REG_H_
|
||||
#define TWL_MCU_ARM7_MCU_REG_H_
|
||||
|
||||
#define MCU_REG_IRQ_ADDR 0x00
|
||||
#define MCU_REG_MODE_ADDR 0x01
|
||||
#define MCU_REG_WIFI_ADDR 0x02
|
||||
#define MCU_REG_CAMERA_ADDR 0x03
|
||||
#define MCU_REG_VOLUME_ADDR 0x04
|
||||
#define MCU_REG_INFO_ADDR 0x05
|
||||
|
||||
#define MCU_REG_TEMP_ADDR 0x06
|
||||
#define MCU_REG_TEMP_LAST_ADDR 0x25
|
||||
|
||||
/* MCU_REG_IRQ */
|
||||
|
||||
#define MCU_REG_IRQ_RESET_SHIFT 0
|
||||
#define MCU_REG_IRQ_RESET_SIZE 1
|
||||
#define MCU_REG_IRQ_RESET_MASK 0x01
|
||||
|
||||
/* MCU_REG_MODE */
|
||||
|
||||
#define MCU_REG_MODE_SYSTEM_SHIFT 0
|
||||
#define MCU_REG_MODE_SYSTEM_SIZE 2
|
||||
#define MCU_REG_MODE_SYSTEM_MASK 0x03
|
||||
|
||||
/* MCU_REG_WIFI */
|
||||
|
||||
#define MCU_REG_WIFI_SHIFT 0
|
||||
#define MCU_REG_WIFI_SIZE 1
|
||||
#define MCU_REG_WIFI_MASK 0x01
|
||||
|
||||
/* MCU_REG_CAMERA */
|
||||
|
||||
#define MCU_REG_CAMERA_PATTERN_SHIFT 4
|
||||
#define MCU_REG_CAMERA_PATTERN_SIZE 4
|
||||
#define MCU_REG_CAMERA_PATTERN_MASK 0xf0
|
||||
|
||||
#define MCU_REG_CAMERA_PARAM_SHIFT 0
|
||||
#define MCU_REG_CAMERA_PARAM_SIZE 4
|
||||
#define MCU_REG_CAMERA_PARAM_MASK 0x0f
|
||||
|
||||
/* MCU_REG_VOL */
|
||||
|
||||
#define MCU_REG_VOLUME_SHIFT 0
|
||||
#define MCU_REG_VOLUME_SIZE 5
|
||||
#define MCU_REG_VOLUME_MASK 0x1f
|
||||
|
||||
/* MCU_REG_INFO */
|
||||
|
||||
#define MCU_REG_INFO_VERSION_SHIFT 4
|
||||
#define MCU_REG_INFO_VERSION_SIZE 4
|
||||
#define MCU_REG_INFO_VERSION_MASK 0xf0
|
||||
|
||||
#define MCU_REG_INFO_REVISION_SHIFT 0
|
||||
#define MCU_REG_INFO_REVISION_SIZE 4
|
||||
#define MCU_REG_INFO_REVISION_MASK 0x0f
|
||||
|
||||
#endif /* TWL_MCU_ARM7_MCU_REG_H_ */
|
||||
Loading…
Reference in New Issue
Block a user