Firmware: SuperCIC detection support
This commit is contained in:
parent
50bca22b6a
commit
8647a252c4
17
src/cic.c
17
src/cic.c
@ -4,7 +4,7 @@
|
||||
#include "uart.h"
|
||||
#include "cic.h"
|
||||
|
||||
char *cicstatenames[3] = { "CIC_OK", "CIC_FAIL", "CIC_PAIR" };
|
||||
char *cicstatenames[4] = { "CIC_OK", "CIC_FAIL", "CIC_PAIR", "CIC_SCIC" };
|
||||
|
||||
void print_cic_state() {
|
||||
printf("CIC state: %s\n", get_cic_statename(get_cic_state()));
|
||||
@ -21,21 +21,22 @@ enum cicstates get_cic_state() {
|
||||
|
||||
state_old = BITBAND(SNES_CIC_STATUS_REG->FIOPIN, SNES_CIC_STATUS_BIT);
|
||||
/* this loop samples at ~10MHz */
|
||||
for(count=0; count<1000; count++) {
|
||||
for(count=0; count<CIC_SAMPLECOUNT; count++) {
|
||||
state = BITBAND(SNES_CIC_STATUS_REG->FIOPIN, SNES_CIC_STATUS_BIT);
|
||||
if(state != state_old) {
|
||||
togglecount++;
|
||||
}
|
||||
state_old = state;
|
||||
}
|
||||
if(togglecount > 20) {
|
||||
printf("%ld\n", togglecount);
|
||||
printf("%ld\n", togglecount);
|
||||
/* CIC_TOGGLE_THRESH_PAIR > CIC_TOGGLE_THRESH_SCIC */
|
||||
if(togglecount > CIC_TOGGLE_THRESH_PAIR) {
|
||||
return CIC_PAIR;
|
||||
}
|
||||
if(state) {
|
||||
} else if(togglecount > CIC_TOGGLE_THRESH_SCIC) {
|
||||
return CIC_SCIC;
|
||||
} else if(state) {
|
||||
return CIC_OK;
|
||||
}
|
||||
return CIC_FAIL;
|
||||
} else return CIC_FAIL;
|
||||
}
|
||||
|
||||
void cic_init(int allow_pairmode) {
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
#ifndef _CIC_H
|
||||
#define _CIC_H
|
||||
|
||||
#define CIC_SAMPLECOUNT (100000)
|
||||
#define CIC_TOGGLE_THRESH_PAIR (2500)
|
||||
#define CIC_TOGGLE_THRESH_SCIC (10)
|
||||
|
||||
#include <arm/NXP/LPC17xx/LPC17xx.h>
|
||||
#include "bits.h"
|
||||
|
||||
enum cicstates { CIC_OK = 0, CIC_FAIL, CIC_PAIR };
|
||||
enum cicstates { CIC_OK = 0, CIC_FAIL, CIC_PAIR, CIC_SCIC };
|
||||
enum cic_region { CIC_NTSC = 0, CIC_PAL };
|
||||
|
||||
void print_cic_state(void);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user