Onda VX747:
* Button driver rework * Backlight driver rework * LCD driver rework git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18543 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3655a32a3e
commit
9407ae838e
7 changed files with 160 additions and 177 deletions
|
@ -42,48 +42,6 @@ static void audiotest(void)
|
|||
__aic_enable_loopback();
|
||||
}
|
||||
|
||||
/* CP0 hazard avoidance. */
|
||||
#define BARRIER __asm__ __volatile__(".set noreorder\n\t" \
|
||||
"nop; nop; nop; nop; nop; nop;\n\t" \
|
||||
".set reorder\n\t")
|
||||
static void show_tlb(void)
|
||||
{
|
||||
#define ASID_MASK 0xFF
|
||||
|
||||
unsigned int old_ctx;
|
||||
unsigned int entry;
|
||||
unsigned int entrylo0, entrylo1, entryhi;
|
||||
unsigned int pagemask;
|
||||
|
||||
cli();
|
||||
|
||||
/* Save old context */
|
||||
old_ctx = (read_c0_entryhi() & 0xff);
|
||||
|
||||
printf("TLB content:");
|
||||
for(entry = 0; entry < 32; entry++)
|
||||
{
|
||||
write_c0_index(entry);
|
||||
BARRIER;
|
||||
tlb_read();
|
||||
BARRIER;
|
||||
entryhi = read_c0_entryhi();
|
||||
entrylo0 = read_c0_entrylo0();
|
||||
entrylo1 = read_c0_entrylo1();
|
||||
pagemask = read_c0_pagemask();
|
||||
printf("%02d: ASID=%02d%s VA=0x%08x", entry, entryhi & ASID_MASK, (entrylo0 & entrylo1 & 1) ? "(G)" : " ", entryhi & ~ASID_MASK);
|
||||
printf("PA0=0x%08x C0=%x %s%s%s", (entrylo0>>6)<<12, (entrylo0>>3) & 7, (entrylo0 & 4) ? "Dirty " : "", (entrylo0 & 2) ? "Valid " : "Invalid ", (entrylo0 & 1) ? "Global" : "");
|
||||
printf("PA1=0x%08x C1=%x %s%s%s", (entrylo1>>6)<<12, (entrylo1>>3) & 7, (entrylo1 & 4) ? "Dirty " : "", (entrylo1 & 2) ? "Valid " : "Invalid ", (entrylo1 & 1) ? "Global" : "");
|
||||
|
||||
printf("pagemask=0x%08x entryhi=0x%08x", pagemask, entryhi);
|
||||
printf("entrylo0=0x%08x entrylo1=0x%08x", entrylo0, entrylo1);
|
||||
}
|
||||
BARRIER;
|
||||
write_c0_entryhi(old_ctx);
|
||||
|
||||
sti();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
kernel_init();
|
||||
|
@ -135,12 +93,15 @@ int main(void)
|
|||
{
|
||||
memset(testdata, 0, 4096);
|
||||
reset_screen();
|
||||
jz_nand_read(2, j, &testdata);
|
||||
jz_nand_read(0, j, &testdata);
|
||||
printf("Page %d", j);
|
||||
int i;
|
||||
for(i=0; i<256; i+=8)
|
||||
for(i=0; i<768; i+=16)
|
||||
{
|
||||
snprintf(msg, 30, "%02c%02c%02c%02c%02c%02c%02c%02c", testdata[i], testdata[i+1], testdata[i+2], testdata[i+3], testdata[i+4], testdata[i+5], testdata[i+6], testdata[i+7]);
|
||||
snprintf(msg, 30, "%02x%02x%02x%02x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x",
|
||||
testdata[i], testdata[i+1], testdata[i+2], testdata[i+3], testdata[i+4], testdata[i+5], testdata[i+6], testdata[i+7],
|
||||
testdata[i+8], testdata[i+9], testdata[i+10], testdata[i+11], testdata[i+12], testdata[i+13], testdata[i+14], testdata[i+15]
|
||||
);
|
||||
printf(msg);
|
||||
}
|
||||
while(!((btn = button_read_device(&touch)) & (BUTTON_VOL_UP|BUTTON_VOL_DOWN)));
|
||||
|
@ -155,8 +116,12 @@ int main(void)
|
|||
while(1)
|
||||
{
|
||||
#ifdef ONDA_VX747
|
||||
#if 1
|
||||
btn = button_get(false);
|
||||
touch = button_get_data();
|
||||
#else
|
||||
btn = button_read_device(&touch);
|
||||
#endif
|
||||
#else
|
||||
btn = button_read_device();
|
||||
#endif
|
||||
|
@ -174,11 +139,6 @@ int main(void)
|
|||
printf("BUTTON_HOLD");
|
||||
asm("break 0x7");
|
||||
}
|
||||
if(btn & BUTTON_VOL_DOWN)
|
||||
{
|
||||
reset_screen();
|
||||
show_tlb();
|
||||
}
|
||||
if(btn & BUTTON_POWER)
|
||||
{
|
||||
power_off();
|
||||
|
|
|
@ -83,10 +83,10 @@
|
|||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
|
||||
/* Main LCD backlight brightness range and defaults */
|
||||
#define MIN_BRIGHTNESS_SETTING 0 /* TODO */
|
||||
#define MAX_BRIGHTNESS_SETTING 127
|
||||
#define DEFAULT_BRIGHTNESS_SETTING 85
|
||||
#define DEFAULT_DIMNESS_SETTING 22
|
||||
#define MIN_BRIGHTNESS_SETTING 100
|
||||
#define MAX_BRIGHTNESS_SETTING 300
|
||||
#define DEFAULT_BRIGHTNESS_SETTING 300 /* "full brightness" */
|
||||
#define DEFAULT_DIMNESS_SETTING 100 /* "most dim" */
|
||||
|
||||
/* Define this if you have a software controlled poweroff */
|
||||
//#define HAVE_SW_POWEROFF
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "lcd.h"
|
||||
#include "lcd-target.h"
|
||||
#include "system-target.h"
|
||||
#include "kernel.h"
|
||||
|
||||
static volatile bool _lcd_on = false;
|
||||
static volatile bool lcd_poweroff = false;
|
||||
|
@ -70,11 +71,18 @@ void lcd_update_rect(int x, int y, int width, int height)
|
|||
|
||||
__dcache_writeback_all(); /* Size of framebuffer is way bigger than cache size */
|
||||
|
||||
while(REG_SLCD_STATE & SLCD_STATE_BUSY);
|
||||
REG_SLCD_CTRL = SLCD_CTRL_DMA_EN;
|
||||
|
||||
REG_DMAC_DMACR = DMAC_DMACR_DMAE;
|
||||
|
||||
while( !(REG_DMAC_DCCSR(0) & DMAC_DCCSR_TT) )
|
||||
asm("nop");
|
||||
yield();
|
||||
|
||||
REG_DMAC_DMACR = 0;
|
||||
|
||||
while(REG_SLCD_STATE & SLCD_STATE_BUSY);
|
||||
REG_SLCD_CTRL = 0;
|
||||
}
|
||||
|
||||
/* Update the display.
|
||||
|
|
|
@ -23,58 +23,74 @@
|
|||
#include "jz4740.h"
|
||||
#include "backlight-target.h"
|
||||
|
||||
#define GPIO_PWM 123
|
||||
#define PWM_CHN 7
|
||||
#define PWM_FULL 101
|
||||
#define GPIO_PWM (32*3)+31
|
||||
#define PWM_CHN 7
|
||||
#define __gpio_as_PWM_CHN __gpio_as_pwm7
|
||||
|
||||
static void set_backlight(int unk, int val)
|
||||
static void set_backlight(int val)
|
||||
{
|
||||
if(val == 0)
|
||||
__gpio_as_pwm7();
|
||||
else
|
||||
{
|
||||
REG_TCU_TCSR(7) |= 2;
|
||||
REG_TCU_TCSR(7) &= ~0x100;
|
||||
int tmp;
|
||||
tmp = (unk/2 + __cpm_get_rtcclk()) / unk;
|
||||
if(tmp > 0xFFFF)
|
||||
tmp = 0xFFFF;
|
||||
|
||||
__tcu_set_half_data(7, (tmp * unk * 1374389535) >> 5);
|
||||
__tcu_set_full_data(7, tmp);
|
||||
|
||||
REG_TCU_TSCR = (1 << 7);
|
||||
REG_TCU_TESR = (1 << 7);
|
||||
/* Taken from the OF */
|
||||
int tmp;
|
||||
tmp = (val/2 + __cpm_get_rtcclk()) / val;
|
||||
if(tmp > 0xFFFF)
|
||||
tmp = 0xFFFF;
|
||||
|
||||
__tcu_enable_pwm_output(7);
|
||||
}
|
||||
__tcu_set_count(7, 0);
|
||||
__tcu_set_half_data(PWM_CHN, (tmp * val * 1374389535) >> 5);
|
||||
__tcu_set_full_data(PWM_CHN, tmp);
|
||||
}
|
||||
|
||||
static void set_backlight_on(void)
|
||||
{
|
||||
__tcu_start_timer_clock(PWM_CHN);
|
||||
|
||||
set_backlight(MAX_BRIGHTNESS_SETTING);
|
||||
|
||||
__tcu_set_count(PWM_CHN, 0);
|
||||
__tcu_start_counter(PWM_CHN);
|
||||
|
||||
__tcu_enable_pwm_output(PWM_CHN);
|
||||
}
|
||||
|
||||
static void set_backlight_off(void)
|
||||
{
|
||||
__tcu_stop_counter(PWM_CHN);
|
||||
__tcu_disable_pwm_output(PWM_CHN);
|
||||
__tcu_stop_timer_clock(PWM_CHN);
|
||||
}
|
||||
|
||||
bool _backlight_init(void)
|
||||
{
|
||||
__gpio_as_pwm7();
|
||||
|
||||
__tcu_stop_counter(7);
|
||||
__tcu_disable_pwm_output(7);
|
||||
|
||||
set_backlight(300, 7);
|
||||
|
||||
__gpio_as_PWM_CHN();
|
||||
__tcu_start_timer_clock(PWM_CHN);
|
||||
|
||||
__tcu_stop_counter(PWM_CHN);
|
||||
__tcu_disable_pwm_output(PWM_CHN);
|
||||
|
||||
__tcu_init_pwm_output_low(PWM_CHN);
|
||||
__tcu_select_rtcclk(PWM_CHN);
|
||||
__tcu_select_clk_div1(PWM_CHN);
|
||||
|
||||
__tcu_mask_half_match_irq(PWM_CHN);
|
||||
__tcu_mask_full_match_irq(PWM_CHN);
|
||||
|
||||
set_backlight_on();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
set_backlight(300, 7);
|
||||
set_backlight_on();
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
set_backlight(300, 0);
|
||||
set_backlight_off();
|
||||
}
|
||||
|
||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
void _backlight_set_brightness(int brightness)
|
||||
{
|
||||
(void)brightness;
|
||||
return;
|
||||
set_backlight(brightness);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -194,8 +194,6 @@ static void _set_lcd_bus(void)
|
|||
REG_SLCD_CFG = (SLCD_CFG_BURST_8_WORD | SLCD_CFG_DWIDTH_16 | SLCD_CFG_CWIDTH_16BIT
|
||||
| SLCD_CFG_CS_ACTIVE_LOW | SLCD_CFG_RS_CMD_LOW | SLCD_CFG_CLK_ACTIVE_FALLING
|
||||
| SLCD_CFG_TYPE_PARALLEL);
|
||||
|
||||
REG_SLCD_CTRL = SLCD_CTRL_DMA_EN;
|
||||
}
|
||||
|
||||
static void _set_lcd_clock(void)
|
||||
|
|
|
@ -22,21 +22,22 @@
|
|||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "jz4740.h"
|
||||
#include "button.h"
|
||||
#include "button-target.h"
|
||||
|
||||
#define BTN_VOL_DOWN (1 << 27)
|
||||
#define BTN_VOL_UP (1 << 0)
|
||||
#define BTN_MENU (1 << 1)
|
||||
#define BTN_OFF (1 << 29)
|
||||
#define BTN_VOL_DOWN (1 << 27)
|
||||
#define BTN_HOLD (1 << 16)
|
||||
#define BTN_MASK (BTN_VOL_DOWN | BTN_VOL_UP \
|
||||
| BTN_MENU | BTN_OFF )
|
||||
#define BTN_MENU (1 << 1)
|
||||
#define BTN_VOL_UP (1 << 0)
|
||||
#define BTN_MASK (BTN_OFF | BTN_VOL_DOWN | \
|
||||
BTN_MENU | BTN_VOL_UP)
|
||||
|
||||
|
||||
#define TS_AD_COUNT 5
|
||||
#define M_SADC_CFG_SNUM ((TS_AD_COUNT - 1) << SADC_CFG_SNUM_BIT)
|
||||
#define TS_AD_COUNT 5
|
||||
#define M_SADC_CFG_SNUM ((TS_AD_COUNT - 1) << SADC_CFG_SNUM_BIT)
|
||||
|
||||
#define SADC_CFG_INIT ( \
|
||||
#define SADC_CFG_INIT ( \
|
||||
(2 << SADC_CFG_CLKOUT_NUM_BIT) | \
|
||||
SADC_CFG_XYZ1Z2 | \
|
||||
M_SADC_CFG_SNUM | \
|
||||
|
@ -45,20 +46,23 @@
|
|||
SADC_CFG_CMD_INT_PEN \
|
||||
)
|
||||
|
||||
static bool pendown_flag = false;
|
||||
static short x_pos = -1, y_pos = -1, datacount = 0;
|
||||
static short stable_x_pos = -1, stable_y_pos = -1;
|
||||
static bool pen_down = false;
|
||||
static int cur_touch = 0;
|
||||
|
||||
bool button_hold(void)
|
||||
static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT;
|
||||
static int touchscreen_buttons[3][3] =
|
||||
{
|
||||
return (~REG_GPIO_PXPIN(3) & BTN_HOLD ? 1 : 0);
|
||||
}
|
||||
{BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT},
|
||||
{BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT},
|
||||
{BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT}
|
||||
};
|
||||
|
||||
void button_init_device(void)
|
||||
{
|
||||
REG_SADC_ENA = 0;
|
||||
REG_SADC_STATE &= (~REG_SADC_STATE);
|
||||
REG_SADC_CTRL = 0x1f;
|
||||
REG_SADC_CTRL = 0x1F;
|
||||
|
||||
__cpm_start_sadc();
|
||||
REG_SADC_CFG = SADC_CFG_INIT;
|
||||
|
@ -71,15 +75,15 @@ void button_init_device(void)
|
|||
REG_SADC_CTRL &= (~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM));
|
||||
REG_SADC_ENA = SADC_ENA_TSEN; //| SADC_ENA_PBATEN | SADC_ENA_SADCINEN);
|
||||
|
||||
__gpio_port_as_input(3, 29);
|
||||
__gpio_port_as_input(3, 27);
|
||||
__gpio_port_as_input(3, 16);
|
||||
__gpio_port_as_input(3, 1);
|
||||
__gpio_port_as_input(3, 0);
|
||||
__gpio_as_input(32*3 + 29);
|
||||
__gpio_as_input(32*3 + 27);
|
||||
__gpio_as_input(32*3 + 16);
|
||||
__gpio_as_input(32*3 + 1);
|
||||
__gpio_as_input(32*3 + 0);
|
||||
}
|
||||
|
||||
static int touch_to_pixels(short x, short y)
|
||||
{
|
||||
{
|
||||
/* X:300 -> 3800 Y:300->3900 */
|
||||
x -= 300;
|
||||
y -= 300;
|
||||
|
@ -102,68 +106,56 @@ static int touch_to_pixels(short x, short y)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool button_hold(void)
|
||||
{
|
||||
return ((~REG_GPIO_PXPIN(3)) & BTN_HOLD ? true : false);
|
||||
}
|
||||
|
||||
int button_read_device(int *data)
|
||||
{
|
||||
if(button_hold())
|
||||
int ret = 0, tmp;
|
||||
|
||||
if((~REG_GPIO_PXPIN(3)) & BTN_HOLD)
|
||||
return 0;
|
||||
|
||||
unsigned int key = ~(__gpio_get_port(3));
|
||||
int ret = 0;
|
||||
|
||||
if(key & BTN_MASK)
|
||||
|
||||
tmp = (~REG_GPIO_PXPIN(3)) & BTN_MASK;
|
||||
|
||||
if(tmp & BTN_VOL_DOWN)
|
||||
ret |= BUTTON_VOL_DOWN;
|
||||
if(tmp & BTN_VOL_UP)
|
||||
ret |= BUTTON_VOL_UP;
|
||||
if(tmp & BTN_MENU)
|
||||
ret |= BUTTON_MENU;
|
||||
if(tmp & BTN_OFF)
|
||||
ret |= BUTTON_POWER;
|
||||
|
||||
if(current_mode == TOUCHSCREEN_BUTTON && cur_touch != 0)
|
||||
{
|
||||
if(key & BTN_VOL_DOWN)
|
||||
ret |= BUTTON_VOL_DOWN;
|
||||
if(key & BTN_VOL_UP)
|
||||
ret |= BUTTON_VOL_UP;
|
||||
if(key & BTN_MENU)
|
||||
ret |= BUTTON_MENU;
|
||||
if(key & BTN_OFF)
|
||||
ret |= BUTTON_POWER;
|
||||
int px_x = cur_touch >> 16;
|
||||
int px_y = cur_touch & 0xFFFF;
|
||||
ret |= touchscreen_buttons[px_y/(LCD_HEIGHT/3)]
|
||||
[px_x/(LCD_WIDTH/3)];
|
||||
}
|
||||
|
||||
if(data != NULL)
|
||||
else if(pen_down)
|
||||
{
|
||||
if(pendown_flag)
|
||||
{
|
||||
*data = touch_to_pixels(stable_x_pos, stable_y_pos);
|
||||
ret |= BUTTON_TOUCH;
|
||||
}
|
||||
else
|
||||
*data = 0;
|
||||
ret |= BUTTON_TOUCH;
|
||||
if(data != NULL)
|
||||
*data = cur_touch;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
static enum touchpad_mode current_mode = TOUCHPAD_POINT;
|
||||
|
||||
static bool touch_available = false;
|
||||
|
||||
static int touchpad_buttons[3][3] =
|
||||
{
|
||||
{BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT},
|
||||
{BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT},
|
||||
{BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT}
|
||||
};
|
||||
|
||||
void touchpad_set_mode(enum touchpad_mode mode)
|
||||
void touchscreen_set_mode(enum touchscreen_mode mode)
|
||||
{
|
||||
current_mode = mode;
|
||||
}
|
||||
|
||||
enum touchpad_mode touchpad_get_mode(void)
|
||||
enum touchscreen_mode touchscreen_get_mode(void)
|
||||
{
|
||||
return current_mode;
|
||||
}
|
||||
|
||||
void button_set_touch_available(void)
|
||||
{
|
||||
touch_available = true;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Interrupt handler */
|
||||
void SADC(void)
|
||||
{
|
||||
|
@ -179,18 +171,17 @@ void SADC(void)
|
|||
/* Pen down IRQ */
|
||||
REG_SADC_CTRL &= (~(SADC_CTRL_PENUM | SADC_CTRL_TSRDYM));
|
||||
REG_SADC_CTRL |= (SADC_CTRL_PENDM);
|
||||
pendown_flag = true;
|
||||
pen_down = true;
|
||||
}
|
||||
if(state & SADC_CTRL_PENUM)
|
||||
{
|
||||
/* Pen up IRQ */
|
||||
REG_SADC_CTRL &= (~SADC_CTRL_PENDM );
|
||||
REG_SADC_CTRL |= SADC_CTRL_PENUM;
|
||||
pendown_flag = false;
|
||||
pen_down = false;
|
||||
x_pos = -1;
|
||||
y_pos = -1;
|
||||
stable_x_pos = -1;
|
||||
stable_y_pos = -1;
|
||||
cur_touch = 0;
|
||||
}
|
||||
if(state & SADC_CTRL_TSRDYM)
|
||||
{
|
||||
|
@ -200,15 +191,15 @@ void SADC(void)
|
|||
|
||||
dat = REG_SADC_TSDAT;
|
||||
|
||||
xData = (dat >> 0) & 0xfff;
|
||||
yData = (dat >> 16) & 0xfff;
|
||||
xData = (dat >> 0) & 0xFFF;
|
||||
yData = (dat >> 16) & 0xFFF;
|
||||
|
||||
dat = REG_SADC_TSDAT;
|
||||
tsz1Data = (dat >> 0) & 0xfff;
|
||||
tsz2Data = (dat >> 16) & 0xfff;
|
||||
tsz1Data = (dat >> 0) & 0xFFF;
|
||||
tsz2Data = (dat >> 16) & 0xFFF;
|
||||
|
||||
if(!pendown_flag)
|
||||
return ;
|
||||
if( !pen_down )
|
||||
return;
|
||||
|
||||
tsz1Data = tsz2Data - tsz1Data;
|
||||
|
||||
|
@ -231,8 +222,7 @@ void SADC(void)
|
|||
{
|
||||
if(x_pos != -1)
|
||||
{
|
||||
stable_x_pos = x_pos;
|
||||
stable_y_pos = y_pos;
|
||||
cur_touch = touch_to_pixels(x_pos, y_pos);
|
||||
x_pos = -1;
|
||||
y_pos = -1;
|
||||
}
|
||||
|
|
|
@ -497,7 +497,7 @@ static inline u32 jz_readl(u32 address)
|
|||
|
||||
#define TXFIFOEP0 USB_FIFO_EP0
|
||||
|
||||
u32 Bulk_in_buf[BULK_IN_BUF_SIZE];
|
||||
u8 *Bulk_in_buf;
|
||||
u32 Bulk_out_buf[BULK_OUT_BUF_SIZE];
|
||||
u32 Bulk_in_size,Bulk_in_finish,Bulk_out_size;
|
||||
u16 handshake_PKT[4]={0,0,0,0};
|
||||
|
@ -560,12 +560,14 @@ void HW_SendPKT(int ep, const u8 *buf, int size)
|
|||
Bulk_in_size - Bulk_in_finish);
|
||||
usb_setb(USB_REG_INCSR, USB_INCSR_INPKTRDY);
|
||||
Bulk_in_finish = Bulk_in_size;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
udcWriteFifo((u8 *)((u32)buf+Bulk_in_finish),
|
||||
fifosize[ep]);
|
||||
usb_setb(USB_REG_INCSR, USB_INCSR_INPKTRDY);
|
||||
Bulk_in_finish += fifosize[ep];
|
||||
Bulk_in_buf = (u8*)buf;
|
||||
}
|
||||
}
|
||||
else //EP0
|
||||
|
@ -645,7 +647,7 @@ static struct {
|
|||
(1 << 7) | 1,// endpoint 2 is IN endpoint
|
||||
2, /* bulk */
|
||||
512,
|
||||
16
|
||||
0
|
||||
},
|
||||
{
|
||||
sizeof(USB_EndPointDescriptor),
|
||||
|
@ -653,7 +655,7 @@ static struct {
|
|||
(0 << 7) | 1,// endpoint 5 is OUT endpoint
|
||||
2, /* bulk */
|
||||
512, /* OUT EP FIFO size */
|
||||
16
|
||||
0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -822,21 +824,27 @@ void usbHandleStandDevReq(u8 *buf)
|
|||
}
|
||||
}
|
||||
|
||||
extern char printfbuf[256];
|
||||
unsigned char nandbuffer[4096];
|
||||
|
||||
void usbHandleVendorReq(u8 *buf)
|
||||
{
|
||||
int ret_state, i;
|
||||
USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf;
|
||||
switch (dreq->bRequest)
|
||||
{
|
||||
case 0xB0:
|
||||
memset(&nandbuffer, 0, 4096);
|
||||
jz_nand_read(dreq->wValue, dreq->wIndex, &nandbuffer);
|
||||
//printf("Read block %d page %d", dreq->wValue, dreq->wIndex);
|
||||
udc_state = IDLE;
|
||||
break;
|
||||
case 0xAB:
|
||||
//for(i=0; i<256; i+=64)
|
||||
HW_SendPKT(0, printfbuf, 64);
|
||||
udc_state = IDLE;
|
||||
HW_SendPKT(1, nandbuffer, 4096);
|
||||
//printf("Send data");
|
||||
//udc_state = BULK_OUT;
|
||||
break;
|
||||
case 0x12:
|
||||
HW_SendPKT(0, "TEST", 4);
|
||||
//printf("Send test");
|
||||
udc_state = IDLE;
|
||||
break;
|
||||
}
|
||||
|
@ -874,7 +882,7 @@ void EP0_Handler (void)
|
|||
byCSR0 = jz_readb(USB_REG_CSR0);
|
||||
|
||||
/* Check for SentStall
|
||||
if sendtall is set ,clear the sendstall bit*/
|
||||
if sendstall is set ,clear the sendstall bit*/
|
||||
if (byCSR0 & USB_CSR0_SENTSTALL)
|
||||
{
|
||||
jz_writeb(USB_REG_CSR0, (byCSR0 & ~USB_CSR0_SENDSTALL));
|
||||
|
@ -942,7 +950,8 @@ void EPIN_Handler(u8 EP)
|
|||
Bulk_in_size - Bulk_in_finish);
|
||||
usb_setw(USB_REG_INCSR, USB_INCSR_INPKTRDY);
|
||||
Bulk_in_finish = Bulk_in_size;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
udcWriteFifo((u8 *)((u32)Bulk_in_buf+Bulk_in_finish),
|
||||
fifosize[EP]);
|
||||
|
@ -1030,6 +1039,8 @@ void __udc_start(void)
|
|||
|
||||
void usb_init_device(void)
|
||||
{
|
||||
REG_USB_REG_POWER &= ~USB_POWER_SOFTCONN;
|
||||
REG_USB_REG_POWER |= USB_POWER_SOFTCONN;
|
||||
__udc_start();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue