ShiboSoftwareDev/am69-cm5
A 55×40 mm 10-layer CM5 carrier board integrating an AM69A98 SoC, 8‑GiB LPDDR4, 32‑GB eMMC, CM5 connectors, clocking, extensive decoupling/EMI filtering, and HDI DDR/ground escape routing.
- Version
- 0.0.7-engineering-draft-20261107-manual-ddr0
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone ShiboSoftwareDev/am69-cm5 # download the package files into ./am69-cm5
tsci add ShiboSoftwareDev/am69-cm5 # add it to your project as @tsci/ShiboSoftwareDev.am69-cm5In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
firmware/boot-controller/protocol.c
#include "protocol.h"
uint16_t ec_crc16(const uint8_t *data,unsigned count) {
uint16_t crc=0xffff;
for(unsigned i=0;i<count;i++) {
crc^=(uint16_t)data[i]<<8;
for(unsigned bit=0;bit<8;bit++)crc=(uint16_t)((crc<<1)^((crc&0x8000)?0x1021:0));
}
return crc;
}
bool ec_protocol_feed(EcProtocol *p,EcPolicy *e,uint8_t byte,uint32_t now,
uint16_t rpm,uint8_t out[EC_FRAME_SIZE]) {
if(!p->used) { if(byte==0xa5)p->frame[p->used++]=byte;return false; }
if(p->used==1) {
if(byte==0x5a)p->frame[p->used++]=byte;
else p->used=byte==0xa5?1:0;
return false;
}
p->frame[p->used++]=byte;
if(p->used<EC_FRAME_SIZE)return false;
p->used=0;
const uint8_t *f=p->frame;
uint16_t crc=(uint16_t)(f[6]|(uint16_t)f[7]<<8);
if(crc!=ec_crc16(f+2,4))return false;
uint8_t cmd=f[2],sequence=f[3];uint16_t value=(uint16_t)(f[4]|(uint16_t)f[5]<<8),answer=0;
bool ok=e->state==EC_ON;
if(ok) {
if(cmd==1){ok=ec_fan_command(e,value,now);answer=e->fan_percent;}
else if(cmd==2)answer=(uint16_t)e->state;
else if(cmd==3){ok=value==0&&ec_off_command(e,false,now);answer=0;}
else if(cmd==4){ok=value==0&&ec_off_command(e,true,now);answer=0;}
else if(cmd==5)answer=rpm;
else ok=false;
}
out[0]=0xa5;out[1]=0x5a;out[2]=ok?(uint8_t)(cmd|0x80):0xff;out[3]=sequence;
out[4]=(uint8_t)answer;out[5]=(uint8_t)(answer>>8);
crc=ec_crc16(out+2,4);out[6]=(uint8_t)crc;out[7]=(uint8_t)(crc>>8);
return true;
}