- USB CDC 경로 복원: #define Serial Serial1 우회 제거 - rp2040js/avr8js/codemirror/xterm/monaco-editor vendor화 - /vendor 정적 라우팅 추가 (Express 5 catch-all 우회) - 부팅 완료 타임아웃 감지 (Serial 출력 없어도 8초 후 RAF 전환) - 리셋 시 Simulator 재생성으로 주변 장치 상태 초기화 - 시리얼 패널의 내부 메시지를 console.log로 이동
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
const ATOMIC_NORMAL = 0;
|
|
const ATOMIC_XOR = 1;
|
|
const ATOMIC_SET = 2;
|
|
const ATOMIC_CLEAR = 3;
|
|
export function atomicUpdate(currentValue, atomicType, newValue) {
|
|
switch (atomicType) {
|
|
case ATOMIC_XOR:
|
|
return currentValue ^ newValue;
|
|
case ATOMIC_SET:
|
|
return currentValue | newValue;
|
|
case ATOMIC_CLEAR:
|
|
return currentValue & ~newValue;
|
|
default:
|
|
console.warn('Atomic update called with invalid writeType', atomicType);
|
|
return newValue;
|
|
}
|
|
}
|
|
export class BasePeripheral {
|
|
constructor(rp2040, name) {
|
|
this.rp2040 = rp2040;
|
|
this.name = name;
|
|
this.rawWriteValue = 0;
|
|
}
|
|
readUint32(offset) {
|
|
this.warn(`Unimplemented peripheral read from 0x${offset.toString(16)}`);
|
|
if (offset > 0x1000) {
|
|
this.warn('Unimplemented read from peripheral in the atomic operation region');
|
|
}
|
|
return 0xffffffff;
|
|
}
|
|
writeUint32(offset, value) {
|
|
this.warn(`Unimplemented peripheral write to 0x${offset.toString(16)}: 0x${value.toString(16)}`);
|
|
}
|
|
writeUint32Atomic(offset, value, atomicType) {
|
|
this.rawWriteValue = value;
|
|
const newValue = atomicType != ATOMIC_NORMAL
|
|
? atomicUpdate(this.readUint32(offset), atomicType, value)
|
|
: value;
|
|
this.writeUint32(offset, newValue);
|
|
}
|
|
debug(msg) {
|
|
this.rp2040.logger.debug(this.name, msg);
|
|
}
|
|
info(msg) {
|
|
this.rp2040.logger.info(this.name, msg);
|
|
}
|
|
warn(msg) {
|
|
this.rp2040.logger.warn(this.name, msg);
|
|
}
|
|
error(msg) {
|
|
this.rp2040.logger.error(this.name, msg);
|
|
}
|
|
}
|
|
export class UnimplementedPeripheral extends BasePeripheral {
|
|
}
|