├── src
├── inc
│ ├── MiataNB.h
│ ├── Simple.h
│ ├── MissingTeeth.h
│ ├── NipponDenso.h
│ ├── Subaru-36-2-2-2.h
│ ├── 9S12C128.h
│ ├── flashGlobals.h
│ ├── flashBurn.h
│ ├── coreVarsGenerator.h
│ ├── derivedVarsGenerator.h
│ ├── decodePacketAndRespond.h
│ ├── blockDetailsLookup.h
│ ├── main.h
│ ├── injectionISRs.h
│ ├── utils.h
│ ├── flashWrite.h
│ ├── commsISRs.h
│ ├── tableLookup.h
│ ├── init.h
│ ├── packetTypes.h
│ ├── memory.h
│ ├── fuelAndIgnitionCalcs.h
│ ├── pagedLocationBuffers.h
│ ├── TunableConfigs.h
│ ├── errorDefines.h
│ ├── decoderInterface.h
│ ├── interrupts.h
│ ├── commsCore.h
│ └── injectorISR.c
├── data
│ ├── thermistors
│ │ └── GM.h
│ ├── configuration
│ │ └── defaultUteConfig.h
│ └── tables
│ │ ├── ign
│ │ └── FE-DOHC.h
│ │ ├── ve
│ │ └── flat80Percent.h
│ │ └── lambda
│ │ ├── flatStoichiometric.h
│ │ └── originalCurve.h
├── decodePacketAndRespond.c
├── IATTransferTable.c
├── CHTTransferTable.c
├── FreeMS2.c
├── doxy
│ ├── mainPage.h
│ └── groups.h
├── staticInit.c
├── miscISRs.c
├── injectionISRs.c
├── interrupts.c
├── FixedConfig1.c
├── FixedConfig2.c
├── memory.x
├── regions.x
├── MiataNB.c
├── Subaru-36-2-2-2.c
├── derivedVarsGenerator.c
└── realtimeISRs.c
├── lib
├── test.packets
│ ├── CarriageReturn.bin
│ ├── GetProgramTitle.bin
│ ├── special.bytes
│ │ ├── ZERO
│ │ ├── escapedESC
│ │ ├── escapedSTOP
│ │ ├── escapedSTART
│ │ ├── ESC
│ │ ├── ONES
│ │ ├── STOP
│ │ └── START
│ ├── GetRevisionNumber.bin
│ ├── serial.monitor.dir
│ │ ├── serial.mon.open.comms
│ │ ├── serial.mon.reset
│ │ ├── serial.mon.erase.all
│ │ ├── serial.mon.read.ppage
│ │ ├── serial.mon.erase.a.page
│ │ ├── serial.mon.read.ioregs1
│ │ ├── serial.mon.read.ioregs2
│ │ ├── serial.mon.read.ioregs3
│ │ ├── serial.mon.read.ioregs4
│ │ ├── serial.mon.read.ioregs5
│ │ ├── serial.mon.read.ioregs6
│ │ ├── serial.mon.read.ioregs7
│ │ ├── serial.mon.read.ioregs8
│ │ ├── serial.mon.set.ppage.38
│ │ ├── serial.mon.set.ppage.39
│ │ ├── serial.mon.set.ppage.3A
│ │ ├── serial.mon.set.ppage.3B
│ │ ├── serial.mon.set.ppage.3C
│ │ ├── serial.mon.set.ppage.3D
│ │ ├── serial.mon.set.ppage.3E
│ │ ├── serial.mon.set.ppage.3F
│ │ ├── serial.mon.read.flash.flag
│ │ ├── serial.mon.clear.flash.flag
│ │ ├── serial.mon.write.to.page.window
│ │ └── serial.mon.write.mass.erase.to.flash.control
│ ├── sample.data
│ │ ├── byte.sequence.0x00-0x3F.size.64
│ │ └── byte.sequence.0x00-0xFF.size.256
│ ├── request.reset.hard.bin
│ ├── request.reset.soft.bin
│ ├── request.block.vemain.ram.bin
│ ├── request.echo.of.request.bin
│ ├── request.firmware.version.bin
│ ├── request.max.packet.size.bin
│ ├── request.block.vemain.flash.bin
│ ├── request.echo.test.pattern.bin
│ ├── request.interface.version.bin
│ ├── broken
│ │ ├── set.main.cell.value.packet
│ │ ├── simple.escape.packet.pass
│ │ ├── request.temp.burn.no.ack.no.addrs
│ │ ├── send.small.object.for.direct.burn
│ │ ├── send.small.object.straight.to.ram
│ │ ├── simple.escape.packet.fail.2starts
│ │ ├── request.interface.no.ack.1.to.2.bin
│ │ ├── request.temp.erase.no.ack.no.addrs
│ │ ├── simple.escape.packet.fail.checksum
│ │ ├── simple.escape.packet.fail.escwrong
│ │ ├── send.small.object.for.direct.burn.1111
│ │ ├── send.small.object.straight.to.ram.1111
│ │ ├── request.echo.no.ack.no.addrs.bad.checksum
│ │ ├── request.interface.no.ack.force.esc.55.bin
│ │ ├── request.interface.no.ack.force.esc.66.bin
│ │ ├── request.interface.no.ack.1.to.2.bad.checksum.bin
│ │ ├── request.interface.no.ack.escaped.esc.1.to.2.bin
│ │ ├── request.interface.no.ack.escaped.stop.1.to.2.bin
│ │ └── request.interface.no.ack.escaped.start.1.to.2.bin
│ ├── request.block.cht.transfer.table.bin
│ ├── request.block.iat.transfer.table.bin
│ ├── request.block.test.transfer.table.bin
│ ├── response.broken.echo.test.pattern.bin
│ ├── negative.tests
│ │ └── request.bad.payload.id.bin
│ ├── request.location.id.details.for.0x0000.bin
│ ├── request.location.id.details.for.0x8000.bin
│ ├── request.location.id.list.type.all.0x00.bin
│ ├── request.location.id.list.type.and.0x02.bin
│ ├── request.partial.block.datalog.stream.type.bin
│ ├── request.location.id.list.type.or.0x01.lookup.bin
│ ├── request.location.id.list.type.or.0x01.none.bin
│ ├── request.burn.ram.to.flash.datalog.stream.type.bin
│ ├── update.block.with.datalog.stream.type.0x00-OFF.bin
│ ├── deprecated
│ │ ├── configure.async.datalog.type.to.0x00-OFF
│ │ └── configure.async.datalog.type.to.0x01-Basic
│ ├── request.location.id.list.type.or.0x01.maintables.bin
│ ├── update.block.with.datalog.stream.type.0x01-Basic.bin
│ ├── update.flash.block.with.datalog.stream.type.0x00-OFF.bin
│ ├── request.location.id.list.type.or.0x01.maintables.or.lookup.bin
│ └── README.txt
└── FreeMS2-SerialMonitor-1.0.s19
├── .gitignore
├── docs
├── DesignDecisions.txt
├── INFO.txt
├── WHY.txt
└── licenses
│ ├── gpl.template.bash
│ ├── gpl.template.c
│ └── gpl.template.h
├── previous-release
└── Note.txt
├── TODO.txt
├── README.txt
└── .project
/src/inc/MiataNB.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/inc/Simple.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/inc/MissingTeeth.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/inc/NipponDenso.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/data/thermistors/GM.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/inc/Subaru-36-2-2-2.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/test.packets/CarriageReturn.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/test.packets/GetProgramTitle.bin:
--------------------------------------------------------------------------------
1 | S
--------------------------------------------------------------------------------
/lib/test.packets/special.bytes/ZERO:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/test.packets/GetRevisionNumber.bin:
--------------------------------------------------------------------------------
1 | Q
--------------------------------------------------------------------------------
/lib/test.packets/special.bytes/escapedESC:
--------------------------------------------------------------------------------
1 | D
--------------------------------------------------------------------------------
/lib/test.packets/special.bytes/escapedSTOP:
--------------------------------------------------------------------------------
1 | 3
--------------------------------------------------------------------------------
/src/data/configuration/defaultUteConfig.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/test.packets/special.bytes/escapedSTART:
--------------------------------------------------------------------------------
1 | U
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.open.comms:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/inc/9S12C128.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/src/inc/9S12C128.h
--------------------------------------------------------------------------------
/lib/test.packets/special.bytes/ESC:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/special.bytes/ESC
--------------------------------------------------------------------------------
/lib/test.packets/special.bytes/ONES:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/special.bytes/ONES
--------------------------------------------------------------------------------
/lib/test.packets/special.bytes/STOP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/special.bytes/STOP
--------------------------------------------------------------------------------
/lib/test.packets/sample.data/byte.sequence.0x00-0x3F.size.64:
--------------------------------------------------------------------------------
1 |
2 |
!"#$%&'()*+,-./0123456789:;<=>?
--------------------------------------------------------------------------------
/lib/test.packets/special.bytes/START:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/special.bytes/START
--------------------------------------------------------------------------------
/lib/test.packets/request.reset.hard.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.reset.hard.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.reset.soft.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.reset.soft.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.block.vemain.ram.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.block.vemain.ram.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.echo.of.request.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.echo.of.request.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.firmware.version.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.firmware.version.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.max.packet.size.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.max.packet.size.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.block.vemain.flash.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.block.vemain.flash.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.echo.test.pattern.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.echo.test.pattern.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.interface.version.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.interface.version.bin
--------------------------------------------------------------------------------
/lib/test.packets/broken/set.main.cell.value.packet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/set.main.cell.value.packet
--------------------------------------------------------------------------------
/lib/test.packets/broken/simple.escape.packet.pass:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/simple.escape.packet.pass
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.reset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.reset
--------------------------------------------------------------------------------
/lib/test.packets/request.block.cht.transfer.table.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.block.cht.transfer.table.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.block.iat.transfer.table.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.block.iat.transfer.table.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.block.test.transfer.table.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.block.test.transfer.table.bin
--------------------------------------------------------------------------------
/lib/test.packets/response.broken.echo.test.pattern.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/response.broken.echo.test.pattern.bin
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.temp.burn.no.ack.no.addrs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.temp.burn.no.ack.no.addrs
--------------------------------------------------------------------------------
/lib/test.packets/broken/send.small.object.for.direct.burn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/send.small.object.for.direct.burn
--------------------------------------------------------------------------------
/lib/test.packets/broken/send.small.object.straight.to.ram:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/send.small.object.straight.to.ram
--------------------------------------------------------------------------------
/lib/test.packets/broken/simple.escape.packet.fail.2starts:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/simple.escape.packet.fail.2starts
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.erase.all:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.erase.all
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ppage:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ppage
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.interface.no.ack.1.to.2.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.interface.no.ack.1.to.2.bin
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.temp.erase.no.ack.no.addrs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.temp.erase.no.ack.no.addrs
--------------------------------------------------------------------------------
/lib/test.packets/broken/simple.escape.packet.fail.checksum:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/simple.escape.packet.fail.checksum
--------------------------------------------------------------------------------
/lib/test.packets/broken/simple.escape.packet.fail.escwrong:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/simple.escape.packet.fail.escwrong
--------------------------------------------------------------------------------
/lib/test.packets/negative.tests/request.bad.payload.id.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/negative.tests/request.bad.payload.id.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.location.id.details.for.0x0000.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.location.id.details.for.0x0000.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.location.id.details.for.0x8000.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.location.id.details.for.0x8000.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.location.id.list.type.all.0x00.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.location.id.list.type.all.0x00.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.location.id.list.type.and.0x02.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.location.id.list.type.and.0x02.bin
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.erase.a.page:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.erase.a.page
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs1
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs2
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs3
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs4
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs5
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs6:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs6
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs7:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs7
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.ioregs8
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.38:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.38
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.39:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.39
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3A:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3A
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3B:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3B
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3C:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3C
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3D:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3D
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3E:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3E
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3F:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.set.ppage.3F
--------------------------------------------------------------------------------
/lib/test.packets/broken/send.small.object.for.direct.burn.1111:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/send.small.object.for.direct.burn.1111
--------------------------------------------------------------------------------
/lib/test.packets/broken/send.small.object.straight.to.ram.1111:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/send.small.object.straight.to.ram.1111
--------------------------------------------------------------------------------
/lib/test.packets/request.partial.block.datalog.stream.type.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.partial.block.datalog.stream.type.bin
--------------------------------------------------------------------------------
/lib/test.packets/sample.data/byte.sequence.0x00-0xFF.size.256:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/sample.data/byte.sequence.0x00-0xFF.size.256
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.read.flash.flag:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.read.flash.flag
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.echo.no.ack.no.addrs.bad.checksum:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.echo.no.ack.no.addrs.bad.checksum
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.interface.no.ack.force.esc.55.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.interface.no.ack.force.esc.55.bin
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.interface.no.ack.force.esc.66.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.interface.no.ack.force.esc.66.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.location.id.list.type.or.0x01.lookup.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.location.id.list.type.or.0x01.lookup.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.location.id.list.type.or.0x01.none.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.location.id.list.type.or.0x01.none.bin
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.clear.flash.flag:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.clear.flash.flag
--------------------------------------------------------------------------------
/lib/test.packets/request.burn.ram.to.flash.datalog.stream.type.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.burn.ram.to.flash.datalog.stream.type.bin
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.write.to.page.window:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.write.to.page.window
--------------------------------------------------------------------------------
/lib/test.packets/update.block.with.datalog.stream.type.0x00-OFF.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/update.block.with.datalog.stream.type.0x00-OFF.bin
--------------------------------------------------------------------------------
/lib/test.packets/deprecated/configure.async.datalog.type.to.0x00-OFF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/deprecated/configure.async.datalog.type.to.0x00-OFF
--------------------------------------------------------------------------------
/lib/test.packets/deprecated/configure.async.datalog.type.to.0x01-Basic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/deprecated/configure.async.datalog.type.to.0x01-Basic
--------------------------------------------------------------------------------
/lib/test.packets/request.location.id.list.type.or.0x01.maintables.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.location.id.list.type.or.0x01.maintables.bin
--------------------------------------------------------------------------------
/lib/test.packets/update.block.with.datalog.stream.type.0x01-Basic.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/update.block.with.datalog.stream.type.0x01-Basic.bin
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.interface.no.ack.1.to.2.bad.checksum.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.interface.no.ack.1.to.2.bad.checksum.bin
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.interface.no.ack.escaped.esc.1.to.2.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.interface.no.ack.escaped.esc.1.to.2.bin
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.interface.no.ack.escaped.stop.1.to.2.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.interface.no.ack.escaped.stop.1.to.2.bin
--------------------------------------------------------------------------------
/lib/test.packets/broken/request.interface.no.ack.escaped.start.1.to.2.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/broken/request.interface.no.ack.escaped.start.1.to.2.bin
--------------------------------------------------------------------------------
/lib/test.packets/update.flash.block.with.datalog.stream.type.0x00-OFF.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/update.flash.block.with.datalog.stream.type.0x00-OFF.bin
--------------------------------------------------------------------------------
/lib/test.packets/request.location.id.list.type.or.0x01.maintables.or.lookup.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/request.location.id.list.type.or.0x01.maintables.or.lookup.bin
--------------------------------------------------------------------------------
/lib/test.packets/serial.monitor.dir/serial.mon.write.mass.erase.to.flash.control:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fredcooke/FreeMS2/HEAD/lib/test.packets/serial.monitor.dir/serial.mon.write.mass.erase.to.flash.control
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | doxygen.output
2 | bin/a.out
3 | docs/doxygen-html/
4 | docs/*.pdf
5 | src/firmware/
6 | src/output/
7 | src/preprocessedc/
8 | src/objects/
9 | src/debug/
10 | src/assembly/*.s
11 | !src/assembly/flashBurn.s
12 |
13 |
--------------------------------------------------------------------------------
/docs/DesignDecisions.txt:
--------------------------------------------------------------------------------
1 | List of decisions that I've made to streamline development and keep code cleaner (at least for a start)
2 |
3 | * No MicroSquirt support.
4 | * No software P&H support. See http://jbperf.com for a solution.
5 | * MS2Extra 3.1.0 sequential pin out (and subsets) only.
6 | * No IAC stepper control
7 |
8 |
--------------------------------------------------------------------------------
/docs/INFO.txt:
--------------------------------------------------------------------------------
1 | Documents specific to FreeMS2 live here. For general purpose MegaSquirt
2 | documentation look here:
3 |
4 | http://www.megamanual.com
5 |
6 | And for MS2Extra documentation visit:
7 |
8 | http://msextra.com/doc/index.html#ms2
9 |
10 | For info on the sequential hardware mods required see:
11 |
12 | http://www.jbperf.com/sequential/index.html
--------------------------------------------------------------------------------
/previous-release/Note.txt:
--------------------------------------------------------------------------------
1 | Please note :
2 |
3 | If you downloaded the latest zipped release these firmware files are current.
4 |
5 | However...
6 |
7 | If you are accessing these files via a Git clone from github.com then these
8 | firmware files are not a representation of the current state of the code.
9 | Rather they are the output from the source as it was at the time of the last
10 | release of the code. Please attempt to build the code if you want the latest
11 | at any given time. Beware that "snapshot" code is NOT guaranteed to work.
12 | Freshly built code can be found in src/firmware/ not in this directory.
13 |
14 |
--------------------------------------------------------------------------------
/lib/test.packets/README.txt:
--------------------------------------------------------------------------------
1 | All packets are zero byte padded for formatting reasons and also to ensure
2 | that we can grab the start out of the middle of a stream.
3 |
4 | Packets to which we expect an error code response live in ./negative.tests/
5 | Special control bytes for our protocol live in ./special.bytes/
6 | Control sequences for the Serial Monitor live in ./serial.monitor/
7 | Old packets that somehow fell out of date live in ./broken/
8 | Deprecated packets that should still work live in ./deprecated/
9 | Useful blocks of sample data live in ./sample.data/
10 |
11 | All other packets at this level of the test.packets directory should work as
12 | described by their filenames!
13 |
14 |
--------------------------------------------------------------------------------
/TODO.txt:
--------------------------------------------------------------------------------
1 | Fix up assembly header and/or code to be correct and possibly even work.
2 | Fix constants regarding tick time and other hardware specific stuff.
3 | Severely cut back on memory usage, migrating everything to flash temporarily
4 | Modify comms to not use big buffers
5 | Update location IDs to match reality
6 | Modify flash write stuff to not use big buffer
7 |
8 | Fix and modify various things commented out in order to get it to build and run:
9 |
10 | all references to RPAGE
11 | all references to tablesA-D
12 | commented out calls to comms, fuel, vars stuff
13 |
14 | Figure out a paging mechanism:
15 |
16 | Probably just tune one thing at a time and burn it before tuning some other
17 | thing. Use pointers to either point at flash or live RAM data if available.
18 |
19 | Configure the ADC setup correctly, and assign to internal vars.
20 |
21 |
--------------------------------------------------------------------------------
/docs/WHY.txt:
--------------------------------------------------------------------------------
1 | An explanation :
2 |
3 | You may be wondering why I have chosen to start this project when the current
4 | MS2Extra firmware does such a good job of running engines. There are a few
5 | reasons for this:
6 |
7 | 1) To provide a Free and Open Source alternative for use with the well tested
8 | and documented MegaSquirt hardware family.
9 | 2) To ensure that there is always a from-source firmware option available for
10 | MS2 users and their vehicles.
11 | 3) To provide something simple and cleanly written for people to modify for
12 | their own purposes that will remain free (libre and gratis) into the future.
13 | 4) For free software and open source purists.
14 | 5) To allow unrestricted modification and improvement of MegaSquirt hardware.
15 |
16 | It is worth reading the information at this page:
17 |
18 | http://en.wikipedia.org/wiki/Gratis_versus_Libre
19 |
20 | Thank you for downloading the FreeMS2 sources.
21 |
--------------------------------------------------------------------------------
/docs/licenses/gpl.template.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # FreeMS2 - Free and Open Source Firmware for MegaSquirt 2
4 | #
5 | # filename here
6 | #
7 | # Copyright 2011 Fred Cooke
8 | #
9 | # This file is part of the FreeMS2 project.
10 | #
11 | # FreeMS2 software is free software: you can redistribute it and/or modify
12 | # it under the terms of the GNU General Public License as published by
13 | # the Free Software Foundation, either version 3 of the License, or
14 | # (at your option) any later version.
15 | #
16 | # FreeMS2 software is distributed in the hope that it will be useful,
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | # GNU General Public License for more details.
20 | #
21 | # You should have received a copy of the GNU General Public License
22 | # along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
23 | #
24 | # Thank you for choosing FreeMS2 to run your engine!
25 |
26 |
27 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | ################## FreeMS2 - Free & Open Source MegaSquirt 2 ##################
2 |
3 | This firmware is intended to run on B&G and compatible MS2 hardware using an
4 | MS2Extra style pin arrangement. Initial functionality will be to operate the
5 | standard MS2 output channels in a manner suitable for testing circuits and
6 | injectors etc. This README will be updated with new progress.
7 |
8 | Before going any further, please ensure you have the latest release or latest
9 | code by visiting :
10 |
11 | http://github.com/fredcooke/FreeMS2
12 |
13 | Note, this code-base is entirely from-scratch and contains absolutely no code
14 | from previous MegaSquirt projects, including but not limited to MS2Extra.
15 |
16 | To find out why this project exists please see the WHY.txt file in ./docs/
17 | To read about what this project will and won't support see the file
18 | DesignDecisions.txt also in ./docs/ For other sources of information see the
19 | file INFO.txt which, again, is also in the ./docs/ directory.
20 |
21 | Please email me with any and all feedback on code, documentation, the system,
22 | anything at all, even subtle and minor stuff:
23 |
24 | fred dot cooke at gmail dot com
25 |
26 | Thanks for playing with FreeMS2 :-)
27 |
28 | Good luck and regards,
29 |
30 | Fred.
31 |
--------------------------------------------------------------------------------
/src/data/tables/ign/FE-DOHC.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 | /** @file FE-DOHC.h
27 | *
28 | * @ingroup dataInitialisers
29 | *
30 | * @brief The OEM naturally aspirated FE-DOHC ignition curve
31 | *
32 | * This file only contains the data to be hash included into the ignition timing
33 | * tables in the timing table files for car specific builds.
34 | *
35 | * @author Mazda
36 | */
37 |
--------------------------------------------------------------------------------
/src/decodePacketAndRespond.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file decodePacketAndRespond.c
28 | * @ingroup communicationsFiles
29 | *
30 | * @brief Empty file to be filled out
31 | * @details Empty file to be filled out in a later release.
32 | *
33 | * @todo TODO Split the functionality out for 0.0.20
34 | *
35 | * @author Fred Cooke
36 | */
37 |
38 |
39 | #define DECODE_PACKET_AND_RESPOND_C
40 | #include "inc/FreeMS2.h"
41 | #include "inc/decodePacketAndRespond.h"
42 |
43 |
44 | // code here
45 |
--------------------------------------------------------------------------------
/src/inc/flashGlobals.h:
--------------------------------------------------------------------------------
1 | /** @file flashGlobals.h
2 | *
3 | * @todo TODO integrate this file with the rest of the masks and other global constants and hash defines etc
4 | *
5 | * FreeMS2 - the open source engine management system
6 | *
7 | * Copyright 2008, 2009 Sean Keys
8 | *
9 | * This file is part of the FreeMS2 project.
10 | *
11 | * FreeMS2 software is free software: you can redistribute it and/or modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation, either version 3 of the License, or
14 | * (at your option) any later version.
15 | *
16 | * FreeMS2 software is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
23 | *
24 | * We ask that if you make any changes to this file you email them upstream to
25 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
26 | *
27 | * Thank you for choosing FreeMS2 to run your engine!
28 | */
29 |
30 |
31 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
32 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
33 | #ifndef FILE_FLASHGLOBALS_H_SEEN
34 | #define FILE_FLASHGLOBALS_H_SEEN
35 |
36 |
37 | #define PVIOL 0x20
38 | #define ACCERR 0x10
39 |
40 |
41 | #else
42 | /* let us know if we are being untidy with headers */
43 | #warning "Header file FLASHGLOBALS_H seen before, sort it out!"
44 | /* end of the wrapper ifdef from the very top */
45 | #endif
46 |
--------------------------------------------------------------------------------
/src/IATTransferTable.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file IATTransferTable.c
28 | * @ingroup dataInitialisers
29 | *
30 | * @brief Inlet Air Temperature Transfer Table
31 | *
32 | * This file exists solely to contain the Inlet Air Temperature thermistor
33 | * transfer function lookup table.
34 | *
35 | * @author Fred Cooke
36 | */
37 |
38 |
39 | #include "inc/FreeMS2.h"
40 |
41 |
42 | /** @brief Inlet Air Temperature Transfer Table
43 | *
44 | * Using this table it is possible to accurately and quickly convert
45 | * a raw ADC reading to a scaled temperature value in degrees Kelvin.
46 | *
47 | * @author FreeTherm
48 | */
49 | const volatile unsigned short IATTransferTable[1024] LOOKUPD = {
50 | #include "data/thermistors/Bosch.h"
51 | };
52 |
--------------------------------------------------------------------------------
/src/CHTTransferTable.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file CHTTransferTable.c
28 | * @ingroup dataInitialisers
29 | *
30 | * @brief Coolant/Head Temperature Transfer Table
31 | *
32 | * This file exists solely to contain the Coolant/Head Temperature thermistor
33 | * transfer function lookup table.
34 | *
35 | * @author Fred Cooke
36 | */
37 |
38 |
39 | #include "inc/FreeMS2.h"
40 |
41 |
42 | /** @brief Coolant/Head Temperature Transfer Table
43 | *
44 | * Using this table it is possible to accurately and quickly convert
45 | * a raw ADC reading to a scaled temperature value in degrees Kelvin.
46 | *
47 | * @author FreeTherm
48 | */
49 | const volatile unsigned short CHTTransferTable[1024] LOOKUPD = {
50 | #include "data/thermistors/Bosch.h"
51 | };
52 |
--------------------------------------------------------------------------------
/src/FreeMS2.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file FreeMS2.c
28 | *
29 | * @brief Here purely for structure
30 | *
31 | * This file creates the symbols for all of the variables. It is
32 | * separated to clarify how much memory is actually being used by
33 | * various parts of the program. This is required because the RX/TX
34 | * buffers and main paged RAM unions show up as occupied data space
35 | * even though they are actually in RAM and not flash.
36 | *
37 | * @author Fred Cooke
38 | */
39 |
40 |
41 | #define FreeMS2_C
42 | #include "inc/FreeMS2.h"
43 |
44 |
45 | /* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
46 | /* &&&&&&&&&&& THIS FILE IS SUPPOSED TO HAVE NO CODE!!! &&&&&&&&&&& */
47 | /* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
48 |
--------------------------------------------------------------------------------
/src/inc/flashBurn.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file flashBurn.h
28 | * @ingroup allHeaders
29 | *
30 | * @brief C header for assembly flash function
31 | *
32 | * Because we need to call the assembly flash burning function from C code an
33 | * extern function declaration is required to allow successful compilation.
34 | */
35 |
36 |
37 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
38 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
39 | #ifndef FLASHBURN_H_SEEN
40 | #define FLASHBURN_H_SEEN
41 |
42 |
43 | extern void StackBurner();
44 |
45 |
46 | #else
47 | /* let us know if we are being untidy with headers */
48 | #warning "Header file FLASHBURN_H seen before, sort it out!"
49 | /* end of the wrapper ifdef from the very top */
50 | #endif
51 |
--------------------------------------------------------------------------------
/src/doxy/mainPage.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 | /** @mainpage FreeMS2
27 | * @anchor doxygenMainPageTop
28 | *
29 | * @b Welcome @b to @b the @b FreeMS2 @b project!
30 | *
31 | * FreeMS2 is a free and open source firmware for MegaSquirt 2 hardware.
32 | * FreeMS2 firmware is intended to be clean and modular with an emphasis on
33 | * readability and quality. All feedback is very much appreciated!
34 | *
35 | * @since The first of January 2011
36 | *
37 | * @b See @b Also:
38 | * - FreeMS2 Git source repository on GitHub.com
39 | *
40 | * @b Licensing:
41 | * - This project is licensed under the GNU GPL v3. The full terms of the license are available here.
42 | */
43 |
44 | /** @file mainPage.h
45 | *
46 | * @ingroup doxygenDocFiles
47 | * @brief Doxygen Main index page definition
48 | */
49 |
--------------------------------------------------------------------------------
/src/inc/coreVarsGenerator.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file coreVarsGenerator.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_COREVARSGENERATOR_H_SEEN
35 | #define FILE_COREVARSGENERATOR_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef COREVARSGENERATOR_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | EXTERN void generateCoreVars(void) LOOKUPF;
52 |
53 |
54 | #undef EXTERN
55 |
56 |
57 | #else
58 | /* let us know if we are being untidy with headers */
59 | #warning "Header file COREVARSGENERATOR_H seen before, sort it out!"
60 | /* end of the wrapper ifdef from the very top */
61 | #endif
62 |
--------------------------------------------------------------------------------
/src/inc/derivedVarsGenerator.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file derivedVarsGenerator.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_DERIVEDVARSGENERATOR_H_SEEN
35 | #define FILE_DERIVEDVARSGENERATOR_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef DERIVEDVARSGENERATOR_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | EXTERN void generateDerivedVars(void) FPAGE_FE;
52 |
53 |
54 | #undef EXTERN
55 |
56 |
57 | #else
58 | /* let us know if we are being untidy with headers */
59 | #warning "Header file DERIVEDVARSGENERATOR_H seen before, sort it out!"
60 | /* end of the wrapper ifdef from the very top */
61 | #endif
62 |
--------------------------------------------------------------------------------
/src/inc/decodePacketAndRespond.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file decodePacketAndRespond.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_DECODE_PACKET_AND_RESPOND_H_SEEN
35 | #define FILE_DECODE_PACKET_AND_RESPOND_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef DECODE_PACKET_AND_RESPOND_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | // to be filled out in 0.0.?
52 |
53 |
54 | #undef EXTERN
55 |
56 |
57 | #else
58 | /* let us know if we are being untidy with headers */
59 | #warning "Header file DECODE_PACKET_AND_RESPOND_H seen before, sort it out!"
60 | /* end of the wrapper ifdef from the very top */
61 | #endif
62 |
--------------------------------------------------------------------------------
/docs/licenses/gpl.template.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - Free and Open Source Firmware for MegaSquirt 2
2 | *
3 | * Copyright 2011 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * Thank you for choosing FreeMS2 to run your engine!
21 | */
22 |
23 | /** @file filename.c
24 | *
25 | * @ingroup putMeInSomeGroups
26 | *
27 | * @brief A summary description only
28 | *
29 | * Description about what this file is intended to contain and
30 | * anything else that is unique and/or notable about it here!
31 | *
32 | * To add a C source file to the project :
33 | * - Copy this file to the source directory with an appropriate name
34 | * - Change the name to your own at the top of the GPL comment
35 | * - Change the filename to the correct one at the top of this comment
36 | * - Change the hash define to the filename uppercased and underscored
37 | * - Remove or adjust the hash include of the matching header
38 | *
39 | * @bug THIS DOCUMENTATION IS FAULTY!!
40 | * @todo REPLACE THIS WITH REAL DOCUMENTATION!!
41 | * @note SOME LAZY DEVELOPER DIDN'T CUSTOMISE THEIR DOCUMENTATION!!
42 | * @warning IMAGINE WHAT THEIR CODE MIGHT BE LIKE IF THEIR DOCUMENTATION IS THIS BAD!!
43 | */
44 |
45 | #define < filename >_C
46 | #include "inc/freeMS2.h"
47 | #include "inc/< filename >.h"
48 |
49 | /** @brief code here!
50 | *
51 | * xyz
52 | *
53 | * @author Fred Cooke
54 | *
55 | * @param ??
56 | *
57 | * @return ??
58 | */
59 | //fn(){}
60 |
--------------------------------------------------------------------------------
/src/inc/blockDetailsLookup.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file blockDetailsLookup.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_BLOCK_DETAILS_LOOKUP_H_SEEN
35 | #define FILE_BLOCK_DETAILS_LOOKUP_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef BLOCK_DETAILS_LOOKUP_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | EXTERN unsigned short lookupBlockDetails(unsigned short, blockDetails*) FPAGE_FE;
52 |
53 |
54 | #undef EXTERN
55 |
56 | #else
57 | /* let us know if we are being untidy with headers */
58 | #warning "Header file BLOCK_DETAILS_LOOKUP_H seen before, sort it out!"
59 | /* end of the wrapper ifdef from the very top */
60 | #endif
61 |
--------------------------------------------------------------------------------
/src/inc/main.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009, 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file main.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_MAIN_H_SEEN
35 | #define FILE_MAIN_H_SEEN
36 |
37 |
38 | #include "FreeMS2.h"
39 | #include "interrupts.h"
40 | #include "utils.h"
41 | #include "init.h"
42 | #include "commsISRs.h"
43 | #include "commsCore.h"
44 | #include "coreVarsGenerator.h"
45 | #include "derivedVarsGenerator.h"
46 | #include "fuelAndIgnitionCalcs.h"
47 | #include "decoderInterface.h"
48 |
49 |
50 | /* Computer Operating Properly reset sequence MC9S12XDP512V2.PDF Section 2.4.1.5 */
51 | #define COP_RESET1 0x55
52 | #define COP_RESET2 0xAA
53 |
54 | // method of ensuring no duplicate logs are sent.
55 | unsigned short lastCalcCount;
56 |
57 |
58 | #else
59 | /* let us know if we are being untidy with headers */
60 | #warning "Header file MAIN_H seen before, sort it out!"
61 | /* end of the wrapper ifdef from the very top */
62 | #endif
63 |
--------------------------------------------------------------------------------
/docs/licenses/gpl.template.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - Free and Open Source Firmware for MegaSquirt 2
2 | *
3 | * Copyright 2011 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * Thank you for choosing FreeMS2 to run your engine!
21 | */
22 |
23 | /** @file filename.h
24 | *
25 | * @ingroup putMeInSomeGroups
26 | *
27 | * no brief description unless global or general purpose
28 | *
29 | * Description about what this file is intended to contain and
30 | * anything else that is unique and/or notable about it here!
31 | *
32 | * To add a file to the project :
33 | * - Copy this file to the source directory with an appropriate name
34 | * - Change the name to your own at the top of the GPL comment
35 | * - Change the filename to the correct one at the top of this comment
36 | * - Change all 4 hash defines to the filename uppercased and underscored
37 | *
38 | * @bug THIS DOCUMENTATION IS FAULTY!!
39 | * @todo REPLACE THIS WITH REAL DOCUMENTATION!!
40 | * @note SOME LAZY DEVELOPER DIDN'T CUSTOMISE THEIR DOCUMENTATION!!
41 | * @warning IMAGINE WHAT THEIR CODE MIGHT BE LIKE IF THEIR DOCUMENTATION IS THIS BAD!!
42 | */
43 |
44 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
45 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
46 | #ifndef FILE_< filename >_H_SEEN
47 | #define FILE_< filename >_H_SEEN
48 |
49 | #ifdef EXTERN
50 | #warning "EXTERN already defined by another header, please sort it out!"
51 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
52 | #endif
53 |
54 | #ifdef < filename >_C
55 | #define EXTERN
56 | #else
57 | #define EXTERN extern
58 | #endif
59 |
60 | // hash defines here
61 |
62 | // declarations here
63 |
64 | #undef EXTERN
65 |
66 | #else
67 | /* let us know if we are being untidy with headers */
68 | #warning "Header file < filename >_H seen before, sort it out!"
69 | /* end of the wrapper ifdef from the very top */
70 | #endif
71 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FreeMS2
4 | The FreeMS2 firmware source project.
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 | ?name?
14 |
15 |
16 |
17 | org.eclipse.cdt.make.core.append_environment
18 | true
19 |
20 |
21 | org.eclipse.cdt.make.core.autoBuildTarget
22 | all
23 |
24 |
25 | org.eclipse.cdt.make.core.buildArguments
26 | -f Makefile
27 |
28 |
29 | org.eclipse.cdt.make.core.buildCommand
30 | make
31 |
32 |
33 | org.eclipse.cdt.make.core.buildLocation
34 | ${workspace_loc:/freeems-vanilla/src}
35 |
36 |
37 | org.eclipse.cdt.make.core.cleanBuildTarget
38 | clean
39 |
40 |
41 | org.eclipse.cdt.make.core.contents
42 | org.eclipse.cdt.make.core.activeConfigSettings
43 |
44 |
45 | org.eclipse.cdt.make.core.enableAutoBuild
46 | false
47 |
48 |
49 | org.eclipse.cdt.make.core.enableCleanBuild
50 | true
51 |
52 |
53 | org.eclipse.cdt.make.core.enableFullBuild
54 | true
55 |
56 |
57 | org.eclipse.cdt.make.core.fullBuildTarget
58 | all
59 |
60 |
61 | org.eclipse.cdt.make.core.stopOnError
62 | true
63 |
64 |
65 | org.eclipse.cdt.make.core.useDefaultBuildCmd
66 | false
67 |
68 |
69 |
70 |
71 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
72 |
73 |
74 |
75 |
76 |
77 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
78 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
79 | org.eclipse.cdt.core.cnature
80 |
81 |
82 |
--------------------------------------------------------------------------------
/src/inc/injectionISRs.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file injectionISRs.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_INJECTION_ISRS_H_SEEN
35 | #define FILE_INJECTION_ISRS_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef INJECTIONISRS_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | /* Staged injector channel bit masks and registers */
52 |
53 | /* Use port K for staged injector output */
54 | #define STAGEDPORT PORTK
55 |
56 | /* Masks for setting and checking stagedOn status var and turning the channel on */
57 | #define STAGED1ON BIT0
58 | #define STAGED2ON BIT1
59 | #define STAGED3ON BIT2
60 | #define STAGED4ON BIT3
61 | #define STAGED5ON BIT4
62 | #define STAGED6ON BIT5
63 |
64 | /* Masks for unsetting stagedOn status var and turning the channel off */
65 | #define STAGED1OFF NBIT0
66 | #define STAGED2OFF NBIT1
67 | #define STAGED3OFF NBIT2
68 | #define STAGED4OFF NBIT3
69 | #define STAGED5OFF NBIT4
70 | #define STAGED6OFF NBIT5
71 |
72 | /* Internal use to decide if staged is actually required or not based on pulsewidth etc */
73 | unsigned char stagedRequired;
74 |
75 |
76 | #undef EXTERN
77 |
78 |
79 | #else
80 | /* let us know if we are being untidy with headers */
81 | #warning "Header file INJECTION_ISRS_H seen before, sort it out!"
82 | /* end of the wrapper ifdef from the very top */
83 | #endif
84 |
--------------------------------------------------------------------------------
/src/inc/utils.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009, 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file utils.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_UTILS_H_SEEN
35 | #define FILE_UTILS_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef UTILS_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 | EXTERN unsigned short safeAdd(unsigned short, unsigned short);
51 | EXTERN unsigned short safeTrim(unsigned short, signed short);
52 | EXTERN unsigned short safeScale(unsigned short, unsigned short);
53 |
54 | EXTERN void sleep(unsigned short) FPAGE_FE;
55 | EXTERN void sleepMicro(unsigned short) FPAGE_FE;
56 |
57 | EXTERN void adjustPWM(void) FPAGE_FE;
58 | EXTERN void setupPagedRAM(unsigned char) FPAGE_F8;
59 | EXTERN void resetToNonRunningState(void) FPAGE_F8;
60 |
61 | EXTERN void sampleEachADC(ADCArray*) FPAGE_F8;
62 | EXTERN void sampleLoopADC(ADCArray*) FPAGE_F8;
63 | //EXTERN void sampleBlockADC(ADCArray*) FPAGE_F8; broken, do not use
64 |
65 | EXTERN unsigned char checksum(unsigned char *, unsigned short) FPAGE_F8;
66 | EXTERN unsigned short stringCopy(unsigned char*, unsigned char*) FPAGE_F8;
67 | EXTERN unsigned short compare(unsigned char*, unsigned char*, unsigned short); // In unpaged flash as it needs to compare paged flash with unpaged things
68 |
69 |
70 | #undef EXTERN
71 |
72 |
73 | #else
74 | /* let us know if we are being untidy with headers */
75 | #warning "Header file UTILS_H seen before, sort it out!"
76 | /* end of the wrapper ifdef from the very top */
77 | #endif
78 |
--------------------------------------------------------------------------------
/src/inc/flashWrite.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Sean Keys
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file flashWrite.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_FLASHWRITE_H_SEEN
35 | #define FILE_FLASHWRITE_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef FLASHWRITE_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | /// @todo TODO add mass erase function and replace ?? with the real value
52 | #define MASS_ERASE 0x?? /* Used to erase 128k flash blocks */
53 | #define WORD_PROGRAM 0x20 /* Word = 2 bytes, this is the minimum write size, 64K of these per block, 512 per sector */
54 | #define SECTOR_ERASE 0x40 /* Sector = 1024 bytes, there are 128 sectors to a block, and 4 blocks to the chip */
55 | /// @todo TODO CBEIF mask hash define - is this still needed?
56 |
57 |
58 | /* The following code must run from unpaged space for obvious reasons. Location explicitly set to text. */
59 | EXTERN unsigned short writeWord(unsigned short*, unsigned short) TEXT;
60 | EXTERN unsigned short eraseSector(unsigned char, unsigned short*) TEXT;
61 | EXTERN unsigned short writeSector(unsigned char, unsigned short*, unsigned char, unsigned short*) TEXT;
62 | EXTERN unsigned short writeBlock(blockDetails*, void*) TEXT;
63 |
64 |
65 | #undef EXTERN
66 |
67 |
68 | #else
69 | /* let us know ifunsigned short writeBlock(unsigned short* flashAddr, unsigned short* RAMAddr, unsigned short size){
70 | * we are being untidy with headers */
71 | #warning "Header file FLASHWRITE_H seen before, sort it out!"
72 | /* end of the wrapper ifdef from the very top */
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/staticInit.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file staticInit.c
28 | *
29 | * @brief Static initialisation of non-zero variables
30 | *
31 | * This file contains static initialisations for fields that require a non-zero
32 | * initial value after reset. Zero fields are taken care of by GCC and doing
33 | * this here means less init time and init code, both good things. Variables
34 | * initialised here are placed together by the compiler in flash and copied up
35 | * to RAM as a linear block before the main method runs. This is significantly
36 | * more efficient than doing them one-by-one in an init routine.
37 | *
38 | * @author Fred Cooke
39 | */
40 |
41 |
42 | #include "inc/FreeMS2.h"
43 |
44 |
45 | unsigned short tachoPeriod = 65535; /* Lowest RPM at start up time. */
46 |
47 | // Values for testing
48 | unsigned short masterPulseWidth = 10;
49 | unsigned short totalAngleAfterReferenceIgnition = 540;
50 | unsigned short totalAngleAfterReferenceInjection = 180;
51 |
52 | /* Setup the pointers to the registers for fueling use, this does NOT work if done in global.c, I still don't know why. */
53 | // injectorMainTimeRegisters[0] = TC2_ADDR;
54 | // injectorMainTimeRegisters[1] = TC3_ADDR;
55 | // injectorMainTimeRegisters[2] = TC4_ADDR;
56 | // injectorMainTimeRegisters[3] = TC5_ADDR;
57 | // injectorMainTimeRegisters[4] = TC6_ADDR;
58 | // injectorMainTimeRegisters[5] = TC7_ADDR;
59 | // injectorMainControlRegisters[0] = TCTL2_ADDR;
60 | // injectorMainControlRegisters[1] = TCTL2_ADDR;
61 | // injectorMainControlRegisters[2] = TCTL1_ADDR;
62 | // injectorMainControlRegisters[3] = TCTL1_ADDR;
63 | // injectorMainControlRegisters[4] = TCTL1_ADDR;
64 | // injectorMainControlRegisters[5] = TCTL1_ADDR;
65 |
66 | // TODO perhaps read from the ds1302 once at start up and init the values or different ones with the actual time and date then update them in RTI
67 |
68 | /* Setup so that the tacho reads low when the engine isn't running */
69 | unsigned long engineCyclePeriod = ticksPerCycleAtOneRPM;
70 |
--------------------------------------------------------------------------------
/src/inc/commsISRs.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file commsISRs.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_COMMS_ISRS_H_SEEN
35 | #define FILE_COMMS_ISRS_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef COMMSISRS_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | /* SCISR1 register fields
52 | *
53 | * From left most/most significant to right most/least significant.
54 | *
55 | * Abrev Description Actions/Meaning
56 | * TRDE - Transmit Data Register Empty - Load with more data if there is any - Main Flag
57 | * TC - Transmit Complete - Nothing being sent and nothing loaded ready - unused
58 | * RDRF - Receive Data Register Full - Store data in buffer until packet complete - Main Flag
59 | * IDLE - Idle Line - Receive line is quiet - unused
60 | * OR - Overrun - Discard partial data received and increment counter
61 | * NF - Noise Flag - Discard partial data received and increment counter
62 | * FE - Framing Error - Discard partial data received and increment counter
63 | * PF - Parity Error - Discard partial data received and increment counter
64 | *
65 | * SCISR1 flag masks */
66 | #define SCISR1_TX_REGISTER_EMPTY BIT7
67 | #define SCISR1_TX_COMPLETE BIT6
68 | #define SCISR1_RX_REGISTER_FULL BIT5
69 | #define SCISR1_RX_IDLE_LINE BIT4
70 | #define SCISR1_RX_OVERRUN BIT3
71 | #define SCISR1_RX_NOISE BIT2
72 | #define SCISR1_RX_FRAMING BIT1
73 | #define SCISR1_RX_PARITY BIT0
74 |
75 |
76 | /* TX/RX state variables */
77 | EXTERN unsigned char TXByteEscaped;
78 | EXTERN unsigned char RXCalculatedChecksum;
79 |
80 |
81 | #undef EXTERN
82 |
83 | #else
84 | /* let us know if we are being untidy with headers */
85 | #warning "Header file COMMS_ISRS_H seen before, sort it out!"
86 | /* end of the wrapper ifdef from the very top */
87 | #endif
88 |
--------------------------------------------------------------------------------
/src/inc/tableLookup.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /* tableLookup.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_TABLELOOKUP_H_SEEN
35 | #define FILE_TABLELOOKUP_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef TABLELOOKUP_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | EXTERN unsigned short lookupTwoDTableUS(twoDTableUS *, unsigned short) TEXT;
52 | EXTERN unsigned short lookupPagedMainTableCellValue(mainTable *, unsigned short, unsigned short, unsigned char) TEXT;
53 |
54 | EXTERN unsigned short setPagedMainTableCellValue(unsigned char, mainTable*, unsigned short, unsigned short, unsigned short) TEXT;
55 | EXTERN unsigned short setPagedMainTableRPMValue(unsigned char, mainTable*, unsigned short, unsigned short) TEXT;
56 | EXTERN unsigned short setPagedMainTableLoadValue(unsigned char, mainTable*, unsigned short, unsigned short) TEXT;
57 |
58 | EXTERN unsigned short setPagedTwoDTableCellValue(unsigned char, twoDTableUS*, unsigned short, unsigned short) TEXT;
59 | EXTERN unsigned short setPagedTwoDTableAxisValue(unsigned char, twoDTableUS*, unsigned short, unsigned short) TEXT;
60 |
61 |
62 | EXTERN unsigned short validateMainTable(mainTable*) TEXT;
63 | EXTERN unsigned short validateTwoDTable(twoDTableUS*) TEXT;
64 |
65 |
66 | /* These might change or might stay the same, so keeping for now */
67 | //EXTERN unsigned short lookup16Bit3dUS(unsigned short*, unsigned short, unsigned short, unsigned short*, unsigned short*, unsigned char, unsigned char); bad wrong.
68 | //EXTERN unsigned char lookup8Bit2dUC(void);
69 | //EXTERN unsigned char lookup8Bit3dUC(void);
70 | //EXTERN signed short lookup16Bit3D(void);
71 | //EXTERN signed char lookup8Bit3D(void);
72 | //EXTERN signed short lookup16Bit2D(void);
73 | //EXTERN signed char lookup8Bit2D(void);
74 |
75 |
76 | #undef EXTERN
77 |
78 |
79 | #else
80 | /* let us know if we are being untidy with headers */
81 | #warning "Header file TABLELOOKUP_H seen before, sort it out!"
82 | /* end of the wrapper ifdef from the very top */
83 | #endif
84 |
--------------------------------------------------------------------------------
/src/miscISRs.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file miscISRs.c
28 | * @ingroup interruptHandlers
29 | *
30 | * @brief Miscellaneous Interrupt Handlers
31 | *
32 | * Various non-descript interrupt handlers that don't really fit anywhere else
33 | * and aren't big enough to live on their own just yet.
34 | *
35 | * @author Fred Cooke
36 | */
37 |
38 |
39 | #include "inc/FreeMS2.h"
40 | #include "inc/interrupts.h"
41 |
42 |
43 | /** @brief Unimplemented Interrupt Handler
44 | *
45 | * Unimplemented interrupt service routine for calls we weren't expecting.
46 | * Currently this simply counts bad calls like any other event type.
47 | *
48 | * @author Fred Cooke
49 | */
50 | void UISR(void){
51 | /* Increment the unimplemented ISR execution counter */
52 | Counters.callsToUISRs++;
53 | }
54 |
55 |
56 | /** @brief Port P pins ISR
57 | *
58 | * Interrupt handler for edge events on port P pins. Not currently used.
59 | *
60 | * @author Fred Cooke
61 | */
62 | void PortPISR(void){
63 | /* Clear all port P flags (we only want one at a time) */
64 | PIFP = ONES;
65 | /* Increment the unimplemented ISR execution counter */
66 | Counters.callsToUISRs++;
67 | } /* Port P interrupt service routine */
68 |
69 |
70 | /** @brief Port J pins ISR
71 | *
72 | * Interrupt handler for edge events on port J pins. Not currently used.
73 | *
74 | * @author Fred Cooke
75 | */
76 | void PortJISR(void){
77 | /* Clear all port H flags (we only want one at a time) */
78 | PIFJ = ONES;
79 | /* Increment the unimplemented ISR execution counter */
80 | Counters.callsToUISRs++;
81 | }
82 |
83 |
84 | /** @brief IRQ/PE1 pin ISR
85 | *
86 | * Interrupt handler for edge events on the IRQ/PE1 pin. Not currently used.
87 | *
88 | * @author Fred Cooke
89 | */
90 | void IRQISR(void){
91 | /* Clear the flag */
92 | // ?? TODO
93 |
94 | /* Increment the unimplemented ISR execution counter */
95 | Counters.callsToUISRs++;
96 | }
97 |
98 |
99 | /** @brief XIRQ/PE0 pin ISR
100 | *
101 | * Interrupt handler for edge events on the XIRQ/PE0 pin. Not currently used.
102 | *
103 | * @author Fred Cooke
104 | */
105 | void XIRQISR(void){
106 | /* Clear the flag */
107 | // ?? TODO
108 |
109 | /* Increment the unimplemented ISR execution counter */
110 | Counters.callsToUISRs++;
111 | }
112 |
113 |
114 | /** @brief Low Voltage Counter
115 | *
116 | * Count how often our voltage drops lower than it should without resetting.
117 | *
118 | * @author Fred Cooke
119 | */
120 | void LowVoltageISR(void){
121 | /* Clear the flag */
122 | VREGCTRL |= 0x01;
123 |
124 | /* Increment the counter */
125 | Counters.lowVoltageConditions++;
126 | }
127 |
--------------------------------------------------------------------------------
/src/injectionISRs.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file injectionISRs.c
28 | * @ingroup interruptHandlers
29 | *
30 | * @brief Injection ISR substitutions
31 | *
32 | * This file defines the pin specific names for each interrupt and all of it's
33 | * pin specific variables then imports the actual code from inc/injectorISR.c
34 | * for each pin such that each one is unique and references a separate set of
35 | * values specific to it while only maintaining a single copy of the code.
36 | *
37 | * @see injectorISR.c
38 | *
39 | * @author Fred Cooke
40 | */
41 |
42 |
43 | #define INJECTIONISRS_C
44 | #include "inc/FreeMS2.h"
45 | #include "inc/interrupts.h"
46 | #include "inc/injectionISRs.h"
47 |
48 |
49 | /* Define the variables correctly for each channel then import the code */
50 |
51 | /* Channel 1 */
52 | #define INJECTOR_CHANNEL_NUMBER 0
53 | #define InjectorXISR Injector1ISR
54 | #define STAGEDXOFF STAGED1OFF
55 | #define STAGEDXON STAGED1ON
56 | #include "inc/injectorISR.c"
57 | #undef InjectorXISR
58 | #undef STAGEDXOFF
59 | #undef STAGEDXON
60 | #undef INJECTOR_CHANNEL_NUMBER
61 |
62 | /* Channel 2 */
63 | #define INJECTOR_CHANNEL_NUMBER 1
64 | #define InjectorXISR Injector2ISR
65 | #define STAGEDXOFF STAGED2OFF
66 | #define STAGEDXON STAGED2ON
67 | #include "inc/injectorISR.c"
68 | #undef InjectorXISR
69 | #undef STAGEDXOFF
70 | #undef STAGEDXON
71 | #undef INJECTOR_CHANNEL_NUMBER
72 |
73 | /* Channel 3 */
74 | #define INJECTOR_CHANNEL_NUMBER 2
75 | #define InjectorXISR Injector3ISR
76 | #define STAGEDXOFF STAGED3OFF
77 | #define STAGEDXON STAGED3ON
78 | #include "inc/injectorISR.c"
79 | #undef InjectorXISR
80 | #undef STAGEDXOFF
81 | #undef STAGEDXON
82 | #undef INJECTOR_CHANNEL_NUMBER
83 |
84 | /* Channel 4 */
85 | #define INJECTOR_CHANNEL_NUMBER 3
86 | #define InjectorXISR Injector4ISR
87 | #define STAGEDXOFF STAGED4OFF
88 | #define STAGEDXON STAGED4ON
89 | #include "inc/injectorISR.c"
90 | #undef InjectorXISR
91 | #undef STAGEDXOFF
92 | #undef STAGEDXON
93 | #undef INJECTOR_CHANNEL_NUMBER
94 |
95 | /* Channel 5 */
96 | #define INJECTOR_CHANNEL_NUMBER 4
97 | #define InjectorXISR Injector5ISR
98 | #define STAGEDXOFF STAGED5OFF
99 | #define STAGEDXON STAGED5ON
100 | #include "inc/injectorISR.c"
101 | #undef InjectorXISR
102 | #undef STAGEDXOFF
103 | #undef STAGEDXON
104 | #undef INJECTOR_CHANNEL_NUMBER
105 |
106 | /* Channel 6 */
107 | #define INJECTOR_CHANNEL_NUMBER 5
108 | #define InjectorXISR Injector6ISR
109 | #define STAGEDXOFF STAGED6OFF
110 | #define STAGEDXON STAGED6ON
111 | #include "inc/injectorISR.c"
112 | #undef InjectorXISR
113 | #undef STAGEDXOFF
114 | #undef STAGEDXON
115 | #undef INJECTOR_CHANNEL_NUMBER
116 |
117 | /* If switching to 8 OC channels with non-IC engine input, place two more sets of defines here :-) (along with all the other mods needed of course) */
118 |
--------------------------------------------------------------------------------
/src/interrupts.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file interrupts.c
28 | * @ingroup interruptHandlers
29 | *
30 | * @brief Interrupt Vector Table
31 | *
32 | * This file contains the definition of the interrupt vector table. This
33 | * table consists only of pointers to void(void) functions that will be
34 | * called by the hardware when an interrupt of a certain type occurs.
35 | *
36 | * @author Fred Cooke
37 | */
38 |
39 |
40 | #include "inc/FreeMS2.h"
41 | #include "inc/interrupts.h"
42 |
43 |
44 | /* Correctly placed in memory due to compiler/linker directives in memory.x and the linker script. */
45 | /* This is the FULL table of length 0xFF starting at 0xFF00 and ending at 0xFFFF, redirected with */
46 | /* jumps to the offset location by the serial monitor starting at 0xF700 and ending at 0xF800 */
47 | /* http://m68hc11.serveftp.org/wiki/index.php/FAQ:Interrupts */
48 | const interruptTable _vectors[] VECTORS = {
49 |
50 | /* 0xFF80 to 0xFF8F */
51 | LowVoltageISR, UISR, UISR, UISR, UISR, UISR, UISR, PortPISR,
52 | /* Low Voltage IIC1 SCI5 SCI4 SCI3 SCI2 PWM ESDown Port P */
53 | /* */
54 |
55 | /* 0xFF90 to 0xFF9F */
56 | UISR, UISR, UISR, UISR, UISR, UISR, UISR, UISR,
57 | /* CAN4 Tx CAN4 Rx CAN4 Errors CAN4 Wakeup CAN3 Tx CAN3 Rx CAN3 Errors CAN3 Wakeup */
58 | /* */
59 |
60 | /* 0xFFA0 to 0xFFAF */
61 | UISR, UISR, UISR, UISR, UISR, UISR, UISR, UISR,
62 | /* CAN2 Tx CAN2 Rx CAN2 Errors CAN2 Wakeup CAN1 Tx CAN1 Rx CAN1 Errors CAN1 Wakeup */
63 | /* */
64 |
65 | /* 0xFFB0 to 0xFFBF */
66 | UISR, UISR, UISR, UISR, UISR, UISR, UISR, UISR,
67 | /* CAN0 Tx CAN0 Rx CAN0 Errors CAN0 Wakeup FLASH EEPROM SPI2 SPI1 */
68 | /* */
69 |
70 | /* 0xFFC0 to 0xFFCF */
71 | UISR, UISR, UISR, UISR, UISR, UISR, UISR, PortJISR,
72 | /* IIC0 Reserved CRG self clock CRG PLL lock PAB Overflow ModDwnCtrUF Port H Port J */
73 | /* */
74 |
75 | /* 0xFFD0 to 0xFFDF */
76 | UISR, UISR, UISR, SCI0ISR, UISR, UISR, UISR, TimerOverflow,
77 | /* ATD1 ATD0? SCI1 SCI0 SPI0 PAIE PAA OF ECT OF */
78 | /* Serial 0 */
79 |
80 | /* 0xFFE0 to 0xFFEF */
81 | Injector6ISR, Injector5ISR, SecondaryRPMISR,Injector4ISR, Injector3ISR, Injector2ISR, Injector1ISR, PrimaryRPMISR,
82 | /* ECT7 ECT6 ECT5 ECT4 ECT3 ECT2 ECT1 ECT0 */
83 | /* IAC2 IAC1 Secondary RPM Injector 4 Injector 3 Injector 2 Injector 1 Primary RPM */
84 |
85 | /* 0xFFF0 to 0xFFFF */
86 | RTIISR, IRQISR, XIRQISR, UISR, UISR, UISR, UISR, _start
87 | /* RTI IRQ XIRQ SWI UnimpInstruct COP Reset ClockReset SystemReset */
88 | /* Entry point */
89 | };
90 |
--------------------------------------------------------------------------------
/src/FixedConfig1.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file FixedConfig1.c
28 | * @ingroup dataInitialisers
29 | *
30 | * @brief First fixed config block
31 | *
32 | * This file contains the definition of the first fixed configuration block.
33 | * The declaration can be found in the global constants header file.
34 | *
35 | * Please ensure that all variables added here have good default values.
36 | *
37 | * @author Fred Cooke
38 | */
39 |
40 |
41 | #include "inc/FreeMS2.h"
42 |
43 |
44 | /// @todo TODO for coreSettingsA masks See definitions in FreeMS2.h OR is it in structs.h ???
45 | /// @todo TODO divide fixedConfig1 into useful chunks
46 | /// @todo TODO create presets sensor values struct
47 | /// @todo TODO create engine setup struct
48 | /// @todo TODO create ranges struct
49 | /// @todo TODO add userTextField1 to the dictionary/address lookup
50 |
51 |
52 | /** @copydoc fixedConfig1 */
53 | const volatile fixedConfig1 fixedConfigs1 FIXEDCONF1 = {
54 |
55 | {
56 | typicalCylinderSize, /* perCylinderVolume */
57 | stoichiometricAFROctane, /* stoichiometricAFR */
58 | typicalInjectorSize, /* injectorFlow */
59 | densityOfOctane, /* densityOfFuelAtSTP */
60 | /* new and old.... */
61 | 575, /* capacityOfAirPerCombustionEvent */
62 | 192, /* perPrimaryInjectorChannelFlowRate */
63 | 192, /* perSecondaryInjectorChannelFlowRate */
64 | 6, /* ports */
65 | 6, /* coils */
66 | 6, /* combustionEventsPerEngineCycle */
67 | 2, /* revolutionsPerEngineCycle */
68 | 24, /* primaryTeeth */
69 | 0 /* missingTeeth */
70 | },
71 |
72 | {
73 | divisorFor115200bps, /* baudDivisor */
74 | 1 /* networkAddress */
75 | },
76 |
77 | {
78 | tachoTickFactor4at50, /* tachoTickFactor */
79 | tachoTotalFactor4at50 /* tachoTotalFactor */
80 | },
81 |
82 | 0x07F0, /* coreSettingsA */
83 |
84 | {"Place your personal notes about whatever you like in here! Don't hesitate to tell us a story about something interesting. Do keep in mind though that when you upload your settings file to the forum this message WILL be visible to all and sundry, so don't be putting too many personal details, bank account numbers, passwords, PIN numbers, license plates, national insurance numbers, IRD numbers, social security numbers, phone numbers, email addresses, love stories and other private information in this field. In fact it is probably best if you keep the information stored here purely related to the vehicle that this system is installed on and relevant to the state of tune and configuration of settings. Lastly, please remember that this field WILL be shrinking in length from it's currently large size to something more reasonable in future. I would like to attempt to keep it at least thirty two characters long though, so writing that much is a non issue, but more won't be possible later!!"}
85 | };
86 |
--------------------------------------------------------------------------------
/src/FixedConfig2.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file FixedConfig2.c
28 | * @ingroup dataInitialisers
29 | *
30 | * @brief Second fixed config block
31 | *
32 | * This file contains the definition of the second fixed configuration block.
33 | * The declaration can be found in the global constants header file.
34 | *
35 | * Please ensure that all variables added here have good default values.
36 | *
37 | * @author Fred Cooke
38 | */
39 |
40 |
41 | #include "inc/FreeMS2.h"
42 |
43 |
44 | /// @todo TODO divide fixedConfig2 into useful chunks
45 | /// @todo TODO create engine hardware config chunk
46 | /// @todo TODO create random stuff chunk
47 | /// @todo TODO add the userTextField2 to the dictionary/address lookup
48 |
49 |
50 | /** @copydoc fixedConfig1 */
51 | const volatile fixedConfig2 fixedConfigs2 FIXEDCONF2 = {
52 | {
53 | roomTemperature, /* presetIAT */
54 | runningTemperature, /* presetCHT */
55 | halfThrottle, /* presetTPS */
56 | stoichiometricLambda, /* presetEGO */
57 | runningVoltage, /* presetBRV */
58 | idleManifoldPressure, /* presetMAP */
59 | seaLevelKPa, /* presetAAP */
60 | roomTemperature, /* presetMAT */
61 | stoichiometricLambda, /* presetEGO2 */
62 | maxExpectedBoost, /* presetIAP */
63 | idlePulseWidth, /* presetBPW */
64 | idleAirFlow /* presetAF */
65 | },
66 |
67 | {
68 | offIdleMAP, /* TPSClosedMAP */
69 | nearlyWOTMAP, /* TPSOpenMAP */
70 | MPX4250AMin, /* MAPMinimum */
71 | MPX4250ARange, /* MAPRange */
72 | MPX4100AMin, /* AAPMinimum */
73 | MPX4100ARange, /* AAPRange */
74 | LC1LambdaMin, /* EGOMinimum */
75 | LC1LambdaRange, /* EGORange */
76 | batteryVoltageMin, /* BRVMinimum */
77 | batteryVoltageRange, /* BRVRange */
78 | TPSDefaultMin, /* TPSMinimumADC */
79 | TPSDefaultMax /* TPSMaximumADC */
80 | },
81 |
82 | {
83 | 500, /* readingTimeout */ /** Default to half a second 60rpm for a 4 cylinder @todo TODO new method of ADC sampling, Always sample ADC async, If no sync, use async ADC readings, otherwise use synced. Do this with pointer to array set at beginning of math */
84 | },
85 |
86 | {"Place your personal notes about whatever you like in here! Don't hesitate to tell us a story about something interesting. Do keep in mind though that when you upload your settings file to the forum this message WILL be visible to all and sundry, so don't be putting too many personal details, bank account numbers, passwords, PIN numbers, license plates, national insurance numbers, IRD numbers, social security numbers, phone numbers, email addresses, love stories and other private information in this field. In fact it is probably best if you keep the information stored here purely related to the vehicle that this system is installed on and relevant to the state of tune and configuration of settings. Lastly, please remember that this field WILL be shrinking in length from it's currently large size to something more reasonable in future. I would like to attempt to keep it at least thirty two characters long though, so writing that much is a non issue, but not more"}
87 | };
88 |
--------------------------------------------------------------------------------
/src/memory.x:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 |
3 | Copyright 2008, 2009 Fred Cooke
4 |
5 | This file is part of the FreeMS2 project.
6 |
7 | FreeMS2 software is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | FreeMS2 software is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 |
20 | We ask that if you make any changes to this file you email them upstream to
21 | us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 |
23 | Thank you for choosing FreeMS2 to run your engine! */
24 |
25 |
26 | /** @file memory.x
27 | *
28 | * @brief Region definition linker script
29 | *
30 | * Memory region location definition file for inclusion into the linker
31 | * script. It defines the names, types, start addresses and lengths of
32 | * each memory region available for the linker to populate with code and
33 | * data. See hc9s12c128elfb.x and regions.x for more information.
34 | *
35 | * A description of what some of this means can be found at the following URLs:
36 | * - http://www.gnu.org/software/m68hc11/m68hc11_binutils.html
37 | * - http://m68hc11.serveftp.org/wiki/index.php/FAQ:Link
38 | *
39 | * @cond memoryscript
40 | */
41 |
42 |
43 | MEMORY
44 | {
45 | /* regs (r) : ORIGIN = 0x0000, LENGTH = 0x0400 /* 1k register space DON'T use! */
46 | /* text3 (rx) : ORIGIN = 0x0400, LENGTH = 0x2C00 *//* 11k of linear flash between regs and ram 3D dont use yet need to clear 3D first */
47 |
48 | /* RAM space split up for tuning and flash burning use as well as GP use */
49 | rxbuf (rw) : ORIGIN = 0x3000, LENGTH = 0x0420 /* ~1k FIXED transmission buffer */
50 | /* rxbuf (rw) : ORIGIN = 0x3420, LENGTH = 0x0410 *//* ~1k FIXED reception buffer */
51 | /* rtune (rw) : ORIGIN = 0x3830, LENGTH = 0x0400 *//* 1k Dynamic area for tuning large etc */
52 | data (rw) : ORIGIN = 0x3420, LENGTH = 0x0BE0 /* ~1k general purpose RAM */
53 |
54 | /* Flash space in linear space while using the page window (16k + 14k + 2k SM = 30k usable, 2k protected) */
55 | text1 (rx) : ORIGIN = 0x4000, LENGTH = 0x3800 /* Unpaged 14k flash block before page window */
56 | fixedconf1 (rx) : ORIGIN = 0x7800, LENGTH = 0x0400 /* Unpaged 1K flash block before page window */
57 | fixedconf2 (rx) : ORIGIN = 0x7C00, LENGTH = 0x0400 /* Unpaged 1K flash block before page window */
58 | /*ppaged (rx) : ORIGIN = 0x8000, LENGTH = 0x4000 16K flash page window, DO NOT USE */
59 | text (rx) : ORIGIN = 0xC000, LENGTH = 0x3780 /* Unpaged 14K flash block after page window minus serial monitor and vector space */
60 | /* TODO split the above text and text1 regions into halves or similar to allow us to know how the linear space is being spent, eg perf/required/isr etc */
61 |
62 | /* Are these correct? */
63 | ppage38 (rx) : ORIGIN = 0x3F0000, LENGTH = 0x4000
64 | fpage39 (rx) : ORIGIN = 0x3F4000, LENGTH = 0x2000
65 | dpage39 (rx) : ORIGIN = 0x3F6000, LENGTH = 0x2000
66 | fpage3A (rx) : ORIGIN = 0x3F8000, LENGTH = 0x2000
67 | dpage3A (rx) : ORIGIN = 0x3FA000, LENGTH = 0x2000
68 | fpage3B (rx) : ORIGIN = 0x3FC000, LENGTH = 0x2000
69 | dpage3B (rx) : ORIGIN = 0x3FE000, LENGTH = 0x2000
70 | fpage3C (rx) : ORIGIN = 0x400000, LENGTH = 0x2000
71 | dpage3C (rx) : ORIGIN = 0x402000, LENGTH = 0x2000
72 | ppage3D (rx) : ORIGIN = 0x404000, LENGTH = 0x4000
73 | /* ppage3E (rx) : ORIGIN = 0x408000, LENGTH = 0x4000 ** Represents 0x4000 - 0x8000 ("text1" paged) */
74 | /* ppage3F (rx) : ORIGIN = 0x40C000, LENGTH = 0x3780 ** Represents 0xC000 - 0xFFFF ("text" paged) */
75 | /* The previous two lines are included for clarity only. */
76 | /* Changes to this file should be reflected in memory.h and Makefile also */
77 | }
78 |
79 | PROVIDE (_stack = 0x4000-1); /* Start the stack immediately after RAM */
80 | /* Vectors are located via the linker command line, not here. */
81 |
82 |
83 | /** @endcond */
84 |
--------------------------------------------------------------------------------
/src/inc/init.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009, 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file init.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_INIT_H_SEEN
35 | #define FILE_INIT_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef INIT_C
45 | #define EXTERN
46 | /* For private internal use of init.c init() function only, hence wrapped in this ifdef */
47 |
48 | /* Keep this non ISR stuff out of linear flash space */
49 | void initPLL(void) FPAGE_FE;
50 | void initIO(void) FPAGE_FE;
51 | void initAllPagedRAM(void) FPAGE_FE;
52 | void initAllPagedAddresses(void) FPAGE_FE;
53 | void initVariables(void) FPAGE_FE;
54 | void initFlash(void) FPAGE_FE;
55 | void initECTTimer(void) FPAGE_FE;
56 | void initSCIStuff(void) FPAGE_FE;
57 | void initConfiguration(void) FPAGE_FE;
58 | void initInterrupts(void) FPAGE_FE;
59 |
60 |
61 | /* Place these functions in the same block of flash as the data upon which they operate! */
62 | void initLookupAddresses(void) LOOKUPF;
63 | void initFuelAddresses(void) FUELTABLESF;
64 | void initTimingAddresses(void) TIMETABLESF;
65 | void initTunableAddresses(void) TUNETABLESF;
66 | void initPagedRAMFuel(void) FUELTABLESF;
67 | void initPagedRAMTime(void) TIMETABLESF;
68 | void initPagedRAMTune(void) TUNETABLESF;
69 |
70 | #else
71 | #define EXTERN extern
72 | #endif
73 |
74 |
75 | /* Other function declarations are private and present in the C */
76 | /* source file purely to assign them to a particular memory region. */
77 | EXTERN void init(void) FPAGE_FE;
78 |
79 |
80 | /* Various masks and values used for initialising the contents of control registers. */
81 | /* For information on how these are being used, try this link : */
82 | /* http://www.vipan.com/htdocs/bitwisehelp.html */
83 |
84 |
85 | // PLL control values
86 | #define PLLLOCK 0x08 /* Mask for checking to see when the PLL loop is locked onto its target */
87 | #define PLLSELOFF 0x7F /* Mask for switching to base external OSCCLK clock 0b_0111_1111 */
88 | #define PLLSELON 0x80 /* Mask for switching to internally multiplied PLL clock 0b_1000_0000 */
89 | #define PLLOFF 0xBF /* Mask for turning the PLLON bit to ZERO 0b_1011_1111, IE, turning PLL off */
90 | #define PLLON 0x40 /* Mask for setting PLLON bit to ONE 0b_0100_0000, IE, turning PLL on */
91 | #define PLLDIVISOR 0x00 /* Input crystal frequency is divided by this number */
92 | #define PLLMULTIPLIER 0x02 /* The result of the above is multiplied by this number to give the bus frequency */
93 |
94 | // Flash control values
95 | #define PRDIV8 0x40 /* Mask for flash module to divide the oscillator clock by 8 */
96 |
97 |
98 | /// @todo TODO define other macros such that raw values aren't used in the code
99 | /// @todo TODO move all the reg masks to a header of their own for general use.
100 |
101 |
102 | #undef EXTERN
103 |
104 |
105 | #else
106 | /* let us know if we are being untidy with headers */
107 | #warning "Header file INIT_H seen before, sort it out!"
108 | /* end of the wrapper ifdef from the very top */
109 | #endif
110 |
--------------------------------------------------------------------------------
/src/regions.x:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 |
3 | Copyright 2008, 2009 Fred Cooke
4 |
5 | This file is part of the FreeMS2 project.
6 |
7 | FreeMS2 software is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | FreeMS2 software is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 |
20 | We ask that if you make any changes to this file you email them upstream to
21 | us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 |
23 | Thank you for choosing FreeMS2 to run your engine! */
24 |
25 |
26 | /** @file regions.x
27 | *
28 | * @brief Region mapping linker script
29 | *
30 | * Code section to memory region mapping definition file for inclusion
31 | * into the linker script. This file provides rules which map pieces of
32 | * code and data from named sections into specific named memory regions.
33 | * See memory.x and hc9s12c128elfb.x for more information.
34 | *
35 | * A description of what some of this means can be found at the following URLs:
36 | * - http://www.gnu.org/software/m68hc11/m68hc11_binutils.html
37 | * - http://m68hc11.serveftp.org/wiki/index.php/FAQ:Link
38 | *
39 | * @cond regionsscript
40 | */
41 |
42 |
43 | SECTIONS
44 | {
45 |
46 | /*&&&&&&&&&&&&&& RAM Regions &&&&&&&&&&&&&&*/
47 |
48 | /* The main RAM region is called "data" and */
49 | /* can be found in the main linker script */
50 |
51 | /* The RAM tuning area. */
52 | /* .rtune :
53 | {
54 | *(.rtune)
55 | } > rtune */
56 |
57 | /* Comms transmission buffer */
58 | /* .txbuf :
59 | {
60 | *(.txbuf)
61 | } > txbuf */
62 |
63 | /* Comms reception buffer */
64 | .rxbuf :
65 | {
66 | *(.rxbuf)
67 | } > rxbuf
68 |
69 | /*&&&&&&&&&&&&&& Linear Flash Regions &&&&&&&&&&&&&&*/
70 |
71 | /* Primary linear code and persistent data is called */
72 | /* "text" and can be found in the main linker script */
73 |
74 | /* Secondary linear code and persistent data */
75 | .text1 :
76 | {
77 | *(.text1)
78 | } > text1
79 |
80 | /* This is the flash page window. */
81 | /* We use this as paged blocks not directly so it's commented out. */
82 | /* .text2 :
83 | {
84 | *(.text2)
85 | } > text2 */
86 |
87 | /* Non live tunable configuration items 1 */
88 | .fixedconf1 :
89 | {
90 | *(.fixedconf1)
91 | } > fixedconf1
92 |
93 | /* Non live tunable configuration items 1 */
94 | .fixedconf2 :
95 | {
96 | *(.fixedconf2)
97 | } > fixedconf2
98 |
99 |
100 | /*&&&&&&&&&&&&&& Paged Flash Regions &&&&&&&&&&&&&&*/
101 |
102 | /* PPAGE 3A is used for fuel tables and setup function */
103 | .dpage3A :
104 | {
105 | *(.dpage3A)
106 | } > dpage3A
107 |
108 | .fpage3A :
109 | {
110 | *(.fpage3A)
111 | } > fpage3A
112 |
113 | /* PPAGE 3B is used for smaller tunables and setup function */
114 | .fpage3B :
115 | {
116 | *(.fpage3B)
117 | } > fpage3B
118 |
119 | /* Data split up into eight chunks to catch size mistakes better */
120 | .dpage3B :
121 | {
122 | *(.dpage3B)
123 | } > dpage3B
124 |
125 | /* PPAGE 3C is used for timing tables and setup function */
126 | .dpage3C :
127 | {
128 | *(.dpage3C)
129 | } > dpage3C
130 |
131 | .fpage3C :
132 | {
133 | *(.fpage3C)
134 | } > fpage3C
135 |
136 | /* The rest from this 128k flash module for general code */
137 | .ppage38 :
138 | {
139 | *(.fpage38)
140 | *(.dpage38)
141 | } > ppage38
142 |
143 | .fpage39 :
144 | {
145 | *(.fpage39)
146 | } > fpage39
147 |
148 | .dpage39 :
149 | {
150 | *(.dpage39)
151 | } > dpage39
152 |
153 | .ppage3D :
154 | {
155 | *(.ppage3D)
156 | } > ppage3D
157 |
158 | /* The following two blocks are included just for clarity */
159 | /* and are the same as text1 and text when paged. */
160 |
161 | /* .ppage3E : (text1 / 0x4000 - 0x7FFF)
162 | {
163 | *(.ppage3E)
164 | } > ppage3E*/
165 |
166 | /* .ppage3F : (text / 0xC000 - 0xFFFF)
167 | {
168 | *(.ppage3F)
169 | } > ppage3F */
170 | }
171 |
172 |
173 | /** @endcond */
174 |
--------------------------------------------------------------------------------
/src/doxy/groups.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 | /** @file groups.h
27 | *
28 | * @ingroup doxygenDocFiles
29 | * @brief Doxygen module groups definition
30 | *
31 | * @note The order of group definitions within this file determines the order
32 | * of them on the modules page so place new groups accordingly.
33 | */
34 |
35 | /** @defgroup interruptHandlers Interrupt Service Routines
36 | *
37 | * These files contain special functions that take no arguments and have void
38 | * return type. They can not take arguments or return anything as they are
39 | * called asynchronously by the hardware through a special jump table that
40 | * contains the start address of each one. Typically these functions take care
41 | * of handling asyncronous external events that are triggered through some sort
42 | * of peripheral module. Examples of types of events that require interrupts
43 | * and associated handlers are listed below.
44 | *
45 | * @b Examples:
46 | * - change of pin voltage state (high to low or vice versa)
47 | * - data received by a communication module
48 | * - buffer for data to be sent by a communication module requires refilling
49 | * - real time clock ticks
50 | * - timer module ticks
51 | */
52 |
53 | /** @defgroup enginePositionRPMDecoders Engine Position/RPM Decoders
54 | *
55 | * All of the code that reads the high speed engine
56 | * position signals can be found linked to from here.
57 | *
58 | * Currently only NipponDenso is semi functional.
59 | */
60 |
61 | /** @defgroup communicationsFiles Communications
62 | *
63 | * All files that are involved in communicating with something outside the MCU
64 | * can be found here.
65 | *
66 | * @b Examples:
67 | * - UART/SCI
68 | * - CAN
69 | * - SPI
70 | * - I2C
71 | */
72 |
73 | /** @defgroup globalHeaders Global Headers
74 | *
75 | * These key files are included in most source files by default.
76 | *
77 | * @b Examples:
78 | * - Global defines
79 | * - Global constants
80 | * - Global variables
81 | * - Error codes
82 | * - Device header
83 | * - Struct typedefs
84 | */
85 |
86 | /** @defgroup dataInitialisers Data Initialisers
87 | *
88 | * These files provide initial data definitions for items that live in flash.
89 | *
90 | * @b Examples:
91 | * - Tables
92 | * - Tunables
93 | * - Fixed config
94 | * - Lookup tables
95 | * - Global constants
96 | */
97 |
98 | /** @defgroup measurementsAndCalculations Measurements And Calculations
99 | *
100 | * These files all operate on inputs in order to eventually generate outputs.
101 | *
102 | * @b Examples:
103 | * - ADC readings
104 | * - Core variable generation
105 | * - Core variable averaging
106 | * - Derived variable generation
107 | * - Fuel calculations
108 | * - Ignition calculations
109 | */
110 |
111 | /** @defgroup allHeaders All Header Files
112 | *
113 | * Most of these are fairly uninteresting, hence being close to the bottom of
114 | * the modules list. Typically they just contain function declarations for
115 | * inclusion in other source files.
116 | */
117 |
118 | /** @defgroup testing Test Files
119 | *
120 | * A very small group at this stage, this is intended to contain various files
121 | * that manipulate the functional code by providing it with artificial inputs
122 | * instead of real values read from sensors.
123 | */
124 |
125 | /** @defgroup doxygenDocFiles Doxygen Documentation Files
126 | *
127 | * These files exist purely to contain documentation for extraction
128 | * by Doxygen. Using this grouping keeps them off the file list.
129 | */
130 |
--------------------------------------------------------------------------------
/src/inc/packetTypes.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009, 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file packetTypes.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_PACKET_TYPES_H_SEEN
35 | #define FILE_PACKET_TYPES_H_SEEN
36 |
37 |
38 | /*&&&&&&&&&&&&&&&&&&&& Payload Type ID Name Value Pairs &&&&&&&&&&&&&&&&&&&&*/
39 |
40 | /* Please note, requests use even ID numbers and their matching responses use */
41 | /* the odd number immediately above the original request ID. There are a few */
42 | /* examples where either a request is not required or a response not sent. In */
43 | /* such cases the odd ID may be used for an packet asyncronously sent from */
44 | /* the EMS to the PC. These will be well commented when present. */
45 |
46 |
47 | /*&&&&&&&&&&&&&&&&&&&&&&&& Protocol Payload Type IDs &&&&&&&&&&&&&&&&&&&&&&&*/
48 |
49 | /* Firmware Independent functions */
50 | #define requestInterfaceVersion 0x0000
51 | #define requestFirmwareVersion 0x0002
52 | #define requestMaxPacketSize 0x0004
53 | #define requestEchoPacketReturn 0x0006
54 | #define requestSoftSystemReset 0x0008 /* System comes up fresh, so no response */
55 | //efine replytoSoftSystemReset 0x0009 /* This is reserved */
56 | #define requestHardSystemReset 0x000A /* System comes up fresh, so no response */
57 | //efine replytoHardSystemReset 0x000B /* This is reserved */
58 | #define requestReInitOfSystem 0x000C /* EXPERIMENTAL, currently responds like normal */
59 | //efine replytoReInitOfSystem 0x000D /* This is reserved */
60 |
61 |
62 | //efine requestAsyncErrorCode 0x000C /* This is reserved */
63 | #define asyncErrorCodePacket 0x000D /* NOTE : Unrequested error event code packet */
64 | //efine requestAsyncDebugInfo 0x000E /* This is reserved */
65 | #define asyncDebugInfoPacket 0x000F /* NOTE : Unrequested debug information packet */
66 |
67 |
68 | /*&&&&&&&&&&&&&&&&&&&&&&&& Firmware Payload Type IDs &&&&&&&&&&&&&&&&&&&&&&&*/
69 |
70 | /* Data block manipulation */
71 | #define updateBlockInRAM 0x0100
72 | #define updateBlockInFlash 0x0102
73 | #define retrieveBlockFromRAM 0x0104
74 | #define retrieveBlockFromFlash 0x0106
75 | #define burnBlockFromRamToFlash 0x0108
76 |
77 | /* Main table manipulation */
78 | #define adjustMainTableCell 0x012C
79 | #define adjustMainTableRPMAxis 0x012E
80 | #define adjustMainTableLoadAxis 0x0130
81 |
82 | /* 2d table manipulation */
83 | #define adjust2dTableAxis 0x0132
84 | #define adjust2dTableCell 0x0134
85 |
86 | /* Datalog request packets */
87 | #define requestBasicDatalog 0x0190
88 | #define responseBasicDatalog 0x0191 /* Defined because it can be used both synchronously and asynchronously */
89 | #define requestConfigurableDatalog 0x0192
90 | #define responseConfigurableDatalog 0x0193 /* Defined because it can be used both synchronously and asynchronously */
91 | #define setAsyncDatalogType 0x0194
92 |
93 | /* Special function */
94 | #define forwardPacketOverCAN 0x01F4
95 | #define forwardPacketOverOtherUART 0x01F6
96 |
97 | /* Generic memory grabber for debugging */
98 | #define retrieveArbitraryMemory 0x0258
99 |
100 | // Data interrogation gold
101 | #define retrieveListOfLocationIDs 0xDA5E // Idea is Dave's, impl is Fred's
102 | #define retrieveLocationIDDetails 0xF8E0 // Idea is Fred's, impl is Fred's
103 |
104 |
105 | #else
106 | /* let us know if we are being untidy with headers */
107 | #warning "Header file PACKET_TYPES_H seen before, sort it out!"
108 | /* end of the wrapper ifdef from the very top */
109 | #endif
110 |
--------------------------------------------------------------------------------
/src/inc/memory.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file memory.h
28 | * @ingroup allHeaders
29 | * @ingroup globalHeaders
30 | *
31 | * @brief Memory usage directives
32 | *
33 | * This file is solely for the definition of compiler memory usage directives.
34 | * Each one is just a short form of the larger statements DFAR and FFAR found
35 | * near the top of this file.
36 | *
37 | * @author Fred Cooke
38 | */
39 |
40 |
41 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
42 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
43 | #ifndef FILE_MEMORY_H_SEEN
44 | #define FILE_MEMORY_H_SEEN
45 |
46 |
47 | /* http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Variable-Attributes.html */
48 |
49 | /* 4k of RAM divided up into special purpose blocks */
50 | #define RTUNE __attribute__ ((section (".rtune"))) /* ~4k paged RAM window */
51 | #define RXBUF __attribute__ ((section (".rxbuf"))) /* ~2k block of RAM for receive buffer */
52 | #define TXBUF __attribute__ ((section (".txbuf"))) /* ~2k block of RAM for transmit buffer */
53 |
54 |
55 | /* Direct flash blocks */
56 | #define FIXEDCONF1 __attribute__ ((section (".fixedconf1"))) /* 1k unpaged block, primary static configuration. */
57 | #define FIXEDCONF2 __attribute__ ((section (".fixedconf2"))) /* 1k unpaged block, secondary static configuration. */
58 | #define TEXT1 __attribute__ ((section (".text1"))) /* 14k unpaged block, must be explicitly used. */
59 | #define TEXT __attribute__ ((section (".text"))) /* 14k unpaged block, code defaults to being stored here. */
60 | /*define SERMON __attribute__ ((section (".sermon"))) 2k unpaged block, occupied by AN2548 serial monitor. */
61 |
62 |
63 | /* far shortcut for data */
64 | #define DFAR(label) __attribute__ ((section (label)))
65 | /* far shortcut for functions */
66 | #define FFAR(label) __attribute__ ((far)) __attribute__ ((section (label)))
67 |
68 |
69 | /* ONLY use the pages below this line for now (Or you won't be able to load them...) */
70 |
71 | /* General Purpose Page with PPAGE = 0x38 */
72 | #define FPAGE_F8 FFAR(".fpage38")
73 | #define DPAGE_F8 DFAR(".dpage38")
74 | #define PAGE_F8_PPAGE 0x38
75 |
76 | /* Function and large lookup tables for ADC to value mapping */
77 | #define LOOKUPF FFAR(".fpage39")
78 | #define LOOKUPD DFAR(".dpage39")
79 | #define LOOKUP_PPAGE 0x39
80 |
81 | /* Fuel tables and the function for copying it up to RAM */
82 | #define FUELTABLESF FFAR(".fpage3A")
83 | #define FUELTABLESD DFAR(".dpage3A")
84 | #define FUELTABLES_PPAGE 0x3A
85 |
86 | /* Tunable tables etc and the function for copying them up to RAM */
87 | #define TUNETABLESF FFAR(".fpage3B")
88 | #define TUNETABLESD DFAR(".dpage3B")
89 | #define TUNETABLES_PPAGE 0x3B
90 |
91 | /* Timing tables and the function for copying them up to RAM */
92 | #define TIMETABLESF FFAR(".fpage3C")
93 | #define TIMETABLESD DFAR(".dpage3C")
94 | #define TIMETABLES_PPAGE 0x3C
95 |
96 | /* General Purpose Page with PPAGE = 0x3D macro names are wrong, but too many files to change to fix for now */
97 | #define FPAGE_FE FFAR(".ppage3D")
98 | #define DPAGE_FE DFAR(".ppage3D")
99 | //#define FPAGE_FE FFAR(".ppage3E") /* Represents 0x4000 - 0x7FFF ("text1" paged) */
100 | //#define DPAGE_FE DFAR(".ppage3E") /* Represents 0x4000 - 0x7FFF ("text1" paged) */
101 | //#define FPAGE_FF FFAR(".ppage3F") /* Represents 0xC000 - 0xFFFF ("text" paged) */
102 | //#define DPAGE_FF DFAR(".ppage3F") /* Represents 0xC000 - 0xFFFF ("text" paged) */
103 | /* The previous four lines are included for clarity only. */
104 | /* Changes to the memory layout should be reflected in memory.x and Makefile also */
105 |
106 |
107 | #else
108 | /* let us know if we are being untidy with headers */
109 | #warning "Header file MEMORY_H seen before, sort it out!"
110 | /* end of the wrapper ifdef from the very top */
111 | #endif
112 |
--------------------------------------------------------------------------------
/src/inc/fuelAndIgnitionCalcs.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file fuelAndIgnitionCalcs.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_FUELANDIGNITIONCALCS_H_SEEN
35 | #define FILE_FUELANDIGNITIONCALCS_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef FUELANDIGNITIONCALCS_C
45 | #define EXTERN
46 | #else
47 | #define EXTERN extern
48 | #endif
49 |
50 |
51 | EXTERN void calculateFuelAndIgnition(void) FPAGE_FE;
52 |
53 |
54 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Always show your working! &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
55 |
56 | /* At least, that is what my teachers used to say 15 years ago ;-) */
57 |
58 | /******************** The full calculations in an unusable form ******************/
59 |
60 | /* Full calcs on a single line */
61 | // final master PW = ((msToTicks * (molarMassOfAir/ molarMassOfAirDivisor) * (airPressure / airPressureDivisor) * (lookedUpVE / (lookedUpVEDivisor * VEpercentageDivisor)) * (perCylinderVolume / perCylinderVolumeDivisor)) / ((universalGasConstant / universalGasConstantDivisor) * (airInletTemp / airInletTempDivisor) * (stoichiometricAFR / stoichiometricAFRDivisor) * (desiredLambda / desiredLambdaDivisor) * (densityOfFuel / (densityOfFuelDivisor * densityOfFuelUnitDivisor)) * (injectorFlow / (injectorFlowUnitDivisor * injectorFlowDivisor))));
62 |
63 | /* stripped with only variables and divisors left.*/
64 | // finalMasterPulseWidth = (((airPressure / airPressureDivisor) * (lookedUpVE / (lookedUpVEDivisor * VEpercentageDivisor))) / ((airInletTemp / airInletTempDivisor) * (desiredLambda / desiredLambdaDivisor) * (densityOfFuel / (densityOfFuelDivisor * densityOfFuelUnitDivisor))));
65 |
66 | /* stripped with only divisors left.*/
67 | // finalMasterPulseWidth = (airInletTempDivisor * oneLambdaDivisor * densityOfFuelTotalDivisor) / (airPressureDivisor * VETotalDivisor) ;
68 |
69 | /* stripped with only divisors left.*/
70 | // divisors = 1;
71 |
72 | /* totally stripped with no divisors */
73 | // finalMasterPulseWidth = ((airPressure * lookedUpVE) / (airInletTemp * desiredLambda * densityOfFuel));
74 |
75 | /**************************** The constant calculations **************************/
76 |
77 | // unsigned short constant;
78 | /* stripped with only constants and divisors left.*/
79 | // constant = ((msToTicks * (molarMassOfAir/ molarMassOfAirDivisor) * (perCylinderVolume / perCylinderVolumeDivisor)) / ((universalGasConstant / universalGasConstantDivisor) * (stoichiometricAFR / stoichiometricAFRDivisor) * (injectorFlow / (injectorFlowUnitDivisor * injectorFlowDivisor))));
80 |
81 | /* stripped with only divisors left. Top divisors go on bottom and bottom on top! */
82 | // constDiv = (universalGasConstantDivisor * stoichiometricAFRDivisor * injectorFlowTotalDivisor) / (molarMassOfAirDivisor * perCylinderVolumeDivisor);
83 | //1310720= (4096 * 1024 * 1024000 ) / (100 * 32768 );
84 |
85 | /* stripped with only constants left.*/
86 | // constant = ((msToTicks * molarMassOfAir * perCylinderVolume) / (universalGasConstant * stoichiometricAFR * injectorFlow));
87 | //nstant = ((1250 * 2897 * 16384 ) / (34056 * 15053 * 4096 ));
88 |
89 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
90 |
91 |
92 | #undef EXTERN
93 |
94 |
95 | #else
96 | /* let us know if we are being untidy with headers */
97 | #warning "Header file FUELANDIGNITIONCALCS_H seen before, sort it out!"
98 | /* end of the wrapper ifdef from the very top */
99 | #endif
100 |
--------------------------------------------------------------------------------
/src/data/tables/ve/flat80Percent.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file flat80Percent.h
28 | *
29 | * @ingroup dataInitialisers
30 | *
31 | * @brief A dead flat 80% VE curve to use as a default for typical engines.
32 | *
33 | * This file only contains the data to be hash included into the VE tables
34 | * in the fuel table files for car specific builds.
35 | *
36 | * @author Fred Cooke
37 | */
38 |
39 |
40 | /* Laid out to make sense for 24 RPM and 19 Load bins, 8 extras on end to make up size. */
41 | /* 80% flat */
42 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
43 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
44 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
45 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
46 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
47 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
48 |
49 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
50 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
51 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
52 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
53 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
54 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
55 |
56 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
57 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
58 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
59 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
60 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
61 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
62 |
63 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
64 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
65 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
66 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
67 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
68 | 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000, 41000,
69 | 41000, 41000, 41000, 41000, 41000, 0xFFFF /* 6 extras to allow different axis sizes. */
70 |
--------------------------------------------------------------------------------
/src/MiataNB.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2009, 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file MiataNB.c
28 | * @ingroup interruptHandlers
29 | * @ingroup enginePositionRPMDecoders
30 | *
31 | * @brief Miata from 9x to 0x
32 | *
33 | * @note Pseudo code that does not compile with zero warnings and errors MUST be commented out.
34 | *
35 | * @todo TODO This file contains SFA but Abe Mara is going to fill it up with
36 | * @todo TODO wonderful goodness very soon ;-)
37 | *
38 | * @author Who Ever
39 | */
40 |
41 |
42 | #include "inc/FreeMS2.h"
43 | #include "inc/interrupts.h"
44 | #include "inc/decoderInterface.h"
45 |
46 |
47 | /** Primary RPM ISR
48 | *
49 | * @todo TODO Docs here!
50 | */
51 | void PrimaryRPMISR(void)
52 | {
53 | /* Clear the interrupt flag for this input compare channel */
54 | TFLG = 0x01;
55 |
56 | /* Save all relevant available data here */
57 | unsigned short codeStartTimeStamp = TCNT; /* Save the current timer count */
58 | unsigned short edgeTimeStamp = TC0; /* Save the edge time stamp */
59 | unsigned char PTITCurrentState = PTIT; /* Save the values on port T regardless of the state of DDRT */
60 | // unsigned short PORTS_BACurrentState = PORTS_BA; /* Save ignition output state */
61 |
62 | /* Calculate the latency in ticks */
63 | ISRLatencyVars.primaryInputLatency = codeStartTimeStamp - edgeTimeStamp;
64 |
65 | // TODO discard narrow ones! test for tooth width and tooth period
66 |
67 | /* Set up edges as per config */
68 | unsigned char risingEdge;
69 | if(fixedConfigs1.coreSettingsA & PRIMARY_POLARITY){
70 | risingEdge = PTITCurrentState & 0x01;
71 | }else{
72 | risingEdge = !(PTITCurrentState & 0x01);
73 | }
74 |
75 | if(risingEdge){
76 | // increment crank pulses TODO this needs to be wrapped in tooth period and width checking
77 | primaryPulsesPerSecondaryPulse++;
78 |
79 | LongTime timeStamp;
80 |
81 | /* Install the low word */
82 | timeStamp.timeShorts[1] = edgeTimeStamp;
83 | /* Find out what our timer value means and put it in the high word */
84 | if(TFLGOF && !(edgeTimeStamp & 0x8000)){ /* see 10.3.5 paragraph 4 of 68hc11 ref manual for details */
85 | timeStamp.timeShorts[0] = timerExtensionClock + 1;
86 | }else{
87 | timeStamp.timeShorts[0] = timerExtensionClock;
88 | }
89 | RuntimeVars.primaryInputLeadingRuntime = TCNT - codeStartTimeStamp;
90 | }else{
91 | RuntimeVars.primaryInputTrailingRuntime = TCNT - codeStartTimeStamp;
92 | }
93 |
94 | Counters.primaryTeethSeen++;
95 | }
96 |
97 |
98 | /** Secondary RPM ISR
99 | *
100 | * @todo TODO Docs here!
101 | */
102 | void SecondaryRPMISR(void)
103 | {
104 | /* Clear the interrupt flag for this input compare channel */
105 | TFLG = 0x02;
106 |
107 | /* Save all relevant available data here */
108 | unsigned short codeStartTimeStamp = TCNT; /* Save the current timer count */
109 | unsigned short edgeTimeStamp = TC1; /* Save the timestamp */
110 | unsigned char PTITCurrentState = PTIT; /* Save the values on port T regardless of the state of DDRT */
111 | // unsigned short PORTS_BACurrentState = PORTS_BA; /* Save ignition output state */
112 |
113 | /* Calculate the latency in ticks */
114 | ISRLatencyVars.secondaryInputLatency = codeStartTimeStamp - edgeTimeStamp;
115 |
116 | // TODO discard narrow ones! test for tooth width and tooth period
117 |
118 | /* Set up edges as per config */
119 | unsigned char risingEdge;
120 | if(fixedConfigs1.coreSettingsA & SECONDARY_POLARITY){
121 | risingEdge = PTITCurrentState & 0x02;
122 | }else{
123 | risingEdge = !(PTITCurrentState & 0x02);
124 | }
125 |
126 | if(risingEdge){
127 | LongTime timeStamp;
128 |
129 | /* Install the low word */
130 | timeStamp.timeShorts[1] = edgeTimeStamp;
131 | /* Find out what our timer value means and put it in the high word */
132 | if(TFLGOF && !(edgeTimeStamp & 0x8000)){ /* see 10.3.5 paragraph 4 of 68hc11 ref manual for details */
133 | timeStamp.timeShorts[0] = timerExtensionClock + 1;
134 | }else{
135 | timeStamp.timeShorts[0] = timerExtensionClock;
136 | }
137 |
138 | RuntimeVars.secondaryInputLeadingRuntime = TCNT - codeStartTimeStamp;
139 | }else{
140 | RuntimeVars.secondaryInputTrailingRuntime = TCNT - codeStartTimeStamp;
141 | }
142 |
143 | Counters.secondaryTeethSeen++;
144 | }
145 |
--------------------------------------------------------------------------------
/src/Subaru-36-2-2-2.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2009, 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file Subaru-36-2-2-2.c
28 | * @ingroup interruptHandlers
29 | * @ingroup enginePositionRPMDecoders
30 | *
31 | * @brief Subaru 36 minus 2 2 2
32 | *
33 | * @note Pseudo code that does not compile with zero warnings and errors MUST be commented out.
34 | *
35 | * @todo TODO This file contains SFA but [anon] is going to fill it up with
36 | * @todo TODO wonderful goodness very soon ;-)
37 | *
38 | * @author Who Ever
39 | */
40 |
41 |
42 | #include "inc/FreeMS2.h"
43 | #include "inc/interrupts.h"
44 | #include "inc/decoderInterface.h"
45 |
46 |
47 | /** Primary RPM ISR
48 | *
49 | * @todo TODO Docs here!
50 | */
51 | void PrimaryRPMISR(void)
52 | {
53 | /* Clear the interrupt flag for this input compare channel */
54 | TFLG = 0x01;
55 |
56 | /* Save all relevant available data here */
57 | unsigned short codeStartTimeStamp = TCNT; /* Save the current timer count */
58 | unsigned short edgeTimeStamp = TC0; /* Save the edge time stamp */
59 | unsigned char PTITCurrentState = PTIT; /* Save the values on port T regardless of the state of DDRT */
60 | // unsigned short PORTS_BACurrentState = PORTS_BA; /* Save ignition output state */
61 |
62 | /* Calculate the latency in ticks */
63 | ISRLatencyVars.primaryInputLatency = codeStartTimeStamp - edgeTimeStamp;
64 |
65 | // TODO discard narrow ones! test for tooth width and tooth period
66 |
67 | /* Set up edges as per config */
68 | unsigned char risingEdge;
69 | if(fixedConfigs1.coreSettingsA & PRIMARY_POLARITY){
70 | risingEdge = PTITCurrentState & 0x01;
71 | }else{
72 | risingEdge = !(PTITCurrentState & 0x01);
73 | }
74 |
75 | if(risingEdge){
76 | // increment crank pulses TODO this needs to be wrapped in tooth period and width checking
77 | primaryPulsesPerSecondaryPulse++;
78 |
79 | LongTime timeStamp;
80 |
81 | /* Install the low word */
82 | timeStamp.timeShorts[1] = edgeTimeStamp;
83 | /* Find out what our timer value means and put it in the high word */
84 | if(TFLGOF && !(edgeTimeStamp & 0x8000)){ /* see 10.3.5 paragraph 4 of 68hc11 ref manual for details */
85 | timeStamp.timeShorts[0] = timerExtensionClock + 1;
86 | }else{
87 | timeStamp.timeShorts[0] = timerExtensionClock;
88 | }
89 | RuntimeVars.primaryInputLeadingRuntime = TCNT - codeStartTimeStamp;
90 | }else{
91 | RuntimeVars.primaryInputTrailingRuntime = TCNT - codeStartTimeStamp;
92 | }
93 |
94 | Counters.primaryTeethSeen++;
95 | }
96 |
97 |
98 | /** Secondary RPM ISR
99 | *
100 | * @todo TODO Docs here!
101 | */
102 | void SecondaryRPMISR(void)
103 | {
104 | /* Clear the interrupt flag for this input compare channel */
105 | TFLG = 0x02;
106 |
107 | /* Save all relevant available data here */
108 | unsigned short codeStartTimeStamp = TCNT; /* Save the current timer count */
109 | unsigned short edgeTimeStamp = TC1; /* Save the timestamp */
110 | unsigned char PTITCurrentState = PTIT; /* Save the values on port T regardless of the state of DDRT */
111 | // unsigned short PORTS_BACurrentState = PORTS_BA; /* Save ignition output state */
112 |
113 | /* Calculate the latency in ticks */
114 | ISRLatencyVars.secondaryInputLatency = codeStartTimeStamp - edgeTimeStamp;
115 |
116 | // TODO discard narrow ones! test for tooth width and tooth period
117 |
118 | /* Set up edges as per config */
119 | unsigned char risingEdge;
120 | if(fixedConfigs1.coreSettingsA & SECONDARY_POLARITY){
121 | risingEdge = PTITCurrentState & 0x02;
122 | }else{
123 | risingEdge = !(PTITCurrentState & 0x02);
124 | }
125 |
126 | if(risingEdge){
127 | LongTime timeStamp;
128 |
129 | /* Install the low word */
130 | timeStamp.timeShorts[1] = edgeTimeStamp;
131 | /* Find out what our timer value means and put it in the high word */
132 | if(TFLGOF && !(edgeTimeStamp & 0x8000)){ /* see 10.3.5 paragraph 4 of 68hc11 ref manual for details */
133 | timeStamp.timeShorts[0] = timerExtensionClock + 1;
134 | }else{
135 | timeStamp.timeShorts[0] = timerExtensionClock;
136 | }
137 |
138 | RuntimeVars.secondaryInputLeadingRuntime = TCNT - codeStartTimeStamp;
139 | }else{
140 | RuntimeVars.secondaryInputTrailingRuntime = TCNT - codeStartTimeStamp;
141 | }
142 |
143 | Counters.secondaryTeethSeen++;
144 | }
145 |
--------------------------------------------------------------------------------
/src/data/tables/lambda/flatStoichiometric.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file flatStoichiometric.h
28 | * @ingroup dataInitialisers
29 | *
30 | * @brief A dead flat stoichiometric 1.0/14.7 Lambda/AFR curve to use as a default or to allow MegaSquirt bodgy style tuning.
31 | *
32 | * This file only contains the data to be hash included into the lambda tables
33 | * in the fuel table files for car specific builds.
34 | *
35 | * @author Fred Cooke
36 | */
37 |
38 |
39 | /* Laid out to make sense for 24 RPM and 19 Load bins, 8 extras on end to make up size. */
40 | /* 14.7 flat */
41 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
42 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
43 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
44 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
45 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
46 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
47 |
48 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
49 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
50 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
51 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
52 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
53 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
54 |
55 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
56 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
57 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
58 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
59 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
60 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
61 |
62 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
63 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
64 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
65 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
66 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
67 | 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,
68 | 32768, 32768, 32768, 32768, 32768, 32768 /* 6 extras to allow different axis sizes. */
69 |
--------------------------------------------------------------------------------
/src/data/tables/lambda/originalCurve.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file originalCurve.h
28 | * @ingroup dataInitialisers
29 | *
30 | * @brief A random stepped Lambda/AFR curve that is probably not a lot of use.
31 | *
32 | * This file only contains the data to be hash included into the lambda tables
33 | * in the fuel table files for car specific builds.
34 | *
35 | * @author Fred Cooke
36 | */
37 |
38 |
39 | /* Laid out to make sense for 24 RPM and 19 Load bins, 8 extras on end to make up size. */
40 | /* 14.7, 14.7, 14.35, 14.0, 13.5, 13.0, 12.5, 12.25, 12.0, 11.75, 11.5, 11.25, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, */
41 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
42 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
43 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
44 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
45 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
46 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
47 |
48 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
49 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
50 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
51 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
52 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
53 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
54 |
55 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
56 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
57 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
58 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
59 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
60 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
61 |
62 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
63 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
64 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
65 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
66 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
67 | 32768, 32768, 31987, 31207, 30093, 28978, 27863, 27307, 26749, 26192, 25635, 25078, 24520, 24520, 24520, 24520, 24520, 24520, 24520,
68 | 24520, 24520, 24520, 24520, 24520, 0x9999 /* 6 extras to allow different axis sizes. Rich by default.*/
69 |
--------------------------------------------------------------------------------
/src/inc/pagedLocationBuffers.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file pagedLocationBuffers.h
28 | * @ingroup allHeaders
29 | *
30 | * @brief Pointers to paged memory blocks
31 | *
32 | * The number of these required is fairly significant and thus is best placed
33 | * in its own header file. Their only function is to prevent warnings from the
34 | * linker due to accessing paged addresses in linear space.
35 | *
36 | * @author Fred Cooke
37 | */
38 |
39 |
40 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
41 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
42 | #ifndef FILE_PAGED_LOCATION_BUFFERS_H_SEEN
43 | #define FILE_PAGED_LOCATION_BUFFERS_H_SEEN
44 |
45 |
46 | #ifdef EXTERN
47 | #warning "EXTERN already defined by another header, please sort it out!"
48 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
49 | #endif
50 |
51 |
52 | #ifdef BLOCK_DETAILS_LOOKUP_C
53 | #define EXTERN
54 | #else
55 | #define EXTERN extern
56 | #endif
57 |
58 |
59 | /*&&&&&&&&&&&&&&&&&&&&& Large 1k or 2k blocks here only &&&&&&&&&&&&&&&&&&&&&*/
60 |
61 | /* Fueling blocks */
62 | EXTERN void* VETableMainFlashLocation;
63 | EXTERN void* VETableMainFlash2Location;
64 | EXTERN void* VETableSecondaryFlashLocation;
65 | EXTERN void* VETableSecondaryFlash2Location;
66 | EXTERN void* VETableTertiaryFlashLocation;
67 | EXTERN void* VETableTertiaryFlash2Location;
68 | EXTERN void* LambdaTableFlashLocation;
69 | EXTERN void* LambdaTableFlash2Location;
70 |
71 | /* Timing blocks */
72 | EXTERN void* IgnitionAdvanceTableMainFlashLocation;
73 | EXTERN void* IgnitionAdvanceTableMainFlash2Location;
74 | EXTERN void* IgnitionAdvanceTableSecondaryFlashLocation;
75 | EXTERN void* IgnitionAdvanceTableSecondaryFlash2Location;
76 | EXTERN void* InjectionAdvanceTableMainFlashLocation;
77 | EXTERN void* InjectionAdvanceTableMainFlash2Location;
78 | EXTERN void* InjectionAdvanceTableSecondaryFlashLocation;
79 | EXTERN void* InjectionAdvanceTableSecondaryFlash2Location;
80 |
81 | /* Tunable blocks */
82 | EXTERN void* SmallTablesAFlashLocation;
83 | EXTERN void* SmallTablesAFlash2Location;
84 | EXTERN void* SmallTablesBFlashLocation;
85 | EXTERN void* SmallTablesBFlash2Location;
86 | EXTERN void* SmallTablesCFlashLocation;
87 | EXTERN void* SmallTablesCFlash2Location;
88 | EXTERN void* SmallTablesDFlashLocation;
89 | EXTERN void* SmallTablesDFlash2Location;
90 |
91 | /* Flash ONLY blocks */
92 | EXTERN void* IATTransferTableLocation;
93 | EXTERN void* CHTTransferTableLocation;
94 | EXTERN void* MAFTransferTableLocation;
95 | EXTERN void* TestTransferTableLocation;
96 |
97 |
98 | /*&&&&&&&&&&&&&&& Small chunks of the above blocks here only! &&&&&&&&&&&&&&&*/
99 |
100 | /* Small chunks of TablesA here */
101 | EXTERN void* dwellDesiredVersusVoltageTableLocation;
102 | EXTERN void* dwellDesiredVersusVoltageTable2Location;
103 | EXTERN void* injectorDeadTimeTableLocation;
104 | EXTERN void* injectorDeadTimeTable2Location;
105 | EXTERN void* postStartEnrichmentTableLocation;
106 | EXTERN void* postStartEnrichmentTable2Location;
107 | EXTERN void* engineTempEnrichmentTableFixedLocation;
108 | EXTERN void* engineTempEnrichmentTableFixed2Location;
109 | EXTERN void* primingVolumeTableLocation;
110 | EXTERN void* primingVolumeTable2Location;
111 | EXTERN void* engineTempEnrichmentTablePercentLocation;
112 | EXTERN void* engineTempEnrichmentTablePercent2Location;
113 | EXTERN void* dwellMaxVersusRPMTableLocation;
114 | EXTERN void* dwellMaxVersusRPMTable2Location;
115 |
116 | /* Small chunks of TablesB here */
117 | EXTERN void* perCylinderFuelTrimsLocation;
118 | EXTERN void* perCylinderFuelTrims2Location;
119 |
120 | /* Small chunks of TablesC here */
121 |
122 | /* Small chunks of TablesD here */
123 |
124 | /* Small chunks of FixedConf1 here */
125 |
126 | /* Small chunks of FixedConf2 here */
127 |
128 | /* Fillers here */
129 | EXTERN void* fillerALocation;
130 | EXTERN void* fillerA2Location;
131 | EXTERN void* fillerBLocation;
132 | EXTERN void* fillerB2Location;
133 | EXTERN void* fillerCLocation;
134 | EXTERN void* fillerC2Location;
135 | EXTERN void* fillerDLocation;
136 | EXTERN void* fillerD2Location;
137 |
138 |
139 | #undef EXTERN
140 |
141 |
142 | #else
143 | /* let us know if we are being untidy with headers */
144 | #warning "Header file PAGED_LOCATION_BUFFERS_H seen before, sort it out!"
145 | /* end of the wrapper ifdef from the very top */
146 | #endif
147 |
--------------------------------------------------------------------------------
/src/inc/TunableConfigs.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009, 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file TunableConfigs.h
28 | * @ingroup allHeaders
29 | * @ingroup globalHeaders
30 | *
31 | * @brief Struct typedefs for tunable configuration
32 | *
33 | * This file contains both the struct data type definitions and the arrays of
34 | * default values for small tables. Place reusable definitions of default table
35 | * values in here such that they can be used in multiple tunable table definitions.
36 | *
37 | * You should add your configuration item here if it is best that it is adjusted with
38 | * instant results on a running engine. For everything else, please consider placing
39 | * it in one of the fixed configuration structs.
40 | *
41 | * @author Fred Cooke
42 | */
43 |
44 |
45 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
46 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
47 | #ifndef FILE_TUNABLE_CONFIGS_H_SEEN
48 | #define FILE_TUNABLE_CONFIGS_H_SEEN
49 |
50 |
51 | /** An array of 16 zeros to fill out currently unused tables. */
52 | #define ARRAY_OF_16_ZEROS { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
53 | /** An array of 16 scaled voltages for use as axes. */
54 | #define ARRAY_OF_16_VOLTAGES { 6000, 7200, 8400, 9000, 9600, 10200, 10800, 11400, 12000, 12600, 13200, 13800, 14400, 17800, 21000, 24500}
55 | /** An array of 16 dwell times in native ticks. */
56 | #define ARRAY_OF_16_DWELLS {10913, 8625, 6975, 6375, 5925, 5513, 5213, 4875, 4613, 4313, 4106, 3900, 3713, 2850, 2138, 1500}
57 | /** An array of 16 injector dead times in native ticks. */
58 | #define ARRAY_OF_16_DEADTIMES { 3638, 2875, 2325, 2125, 1975, 1838, 1738, 1625, 1538, 1438, 1369, 1300, 1238, 950, 713, 500}
59 | /** An array of 16 temperatures in Kelvin. */
60 | #define ARRAY_OF_16_TEMPS {24315, 25315, 26315, 27315, 28315, 29315, 30315, 31315, 32315, 33315, 34315, 35315, 36315, 37315, 38315, 39315}
61 | /** An array of 16 percentages for temperature based enrichment. */
62 | #define ARRAY_OF_16_PERCENTS {49152, 47513, 45875, 44237, 42598, 40960, 39321, 37683, 36045, 34406, 33587, 32768, 32768, 34406, 36045, 39321}
63 | /** Any array of 16 RPM values forAxis values for use as axes. TODO fill out values */
64 | #define ARRAY_OF_16_RPMS { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
65 | /** An array of 6 percentage fuel trims, the value is 100%. */
66 | #define ARRAY_OF_6_FUEL_TRIMS {32768, 32768, 32768, 32768, 32768, 32768}
67 |
68 |
69 | /**
70 | * One of four structs of live tunable data such as small tables and fuel trims
71 | * etc. If you add something here, please ensure you update all of the following :
72 | * - Default values in the initial definitions in TunableConfig.c and TunableConfig2.c
73 | * - The address values within the initPagedRAMTune() function in init.c
74 | * - The lookupBlockDetails() function in blockDetailsLookup.c
75 | * - The JSON data map and other related firmware interface definition files
76 | *
77 | * @todo TODO add doxy comments for each element of the struct
78 | */
79 | typedef struct {
80 | twoDTableUS dwellDesiredVersusVoltageTable;
81 | twoDTableUS injectorDeadTimeTable;
82 | twoDTableUS postStartEnrichmentTable;
83 | twoDTableUS engineTempEnrichmentTableFixed;
84 | /// @todo TODO define units. perhaps micro litres (cubic milli meters) would be good, 5 - 100 seem to be the norm 327.68 = 65535/200
85 | twoDTableUS primingVolumeTable;
86 | twoDTableUS engineTempEnrichmentTablePercent;
87 | twoDTableUS dwellMaxVersusRPMTable;
88 | unsigned char filler[SMALL_TABLES_1_FILLER_SIZE];
89 | } SmallTables1;
90 |
91 |
92 | /** @copydoc SmallTables1 */
93 | typedef struct {
94 | unsigned char datalogStreamType;
95 | unsigned short perCylinderFuelTrims[INJECTION_CHANNELS]; /* Trims for injection, from 0% to 200% of base */
96 | unsigned char filler[SMALL_TABLES_2_FILLER_SIZE];
97 | } SmallTables2;
98 |
99 |
100 | /** @copydoc SmallTables1 */
101 | typedef struct {
102 | unsigned char filler[SMALL_TABLES_3_FILLER_SIZE];
103 | } SmallTables3;
104 |
105 |
106 | /** @copydoc SmallTables1 */
107 | typedef struct {
108 | unsigned char filler[SMALL_TABLES_4_FILLER_SIZE];
109 | } SmallTables4;
110 |
111 |
112 | #else
113 | /* let us know if we are being untidy with headers */
114 | #warning "Header file TUNABLE_CONFIGS_H seen before, sort it out!"
115 | /* end of the wrapper ifdef from the very top */
116 | #endif
117 |
--------------------------------------------------------------------------------
/src/inc/errorDefines.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file errorDefines.h
28 | * @ingroup allHeaders
29 | * @ingroup globalHeaders
30 | *
31 | * @brief Error ID hash defines
32 | *
33 | * This file contains all error codes for propagation up and out to a PC.
34 | * When adding new codes, ensure that they are unique and also that you
35 | * group them appropriately in ranges for easy visual identification.
36 | *
37 | * @author Fred Cooke
38 | */
39 |
40 |
41 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
42 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
43 | #ifndef FILE_ERRORDEFINES_H_SEEN
44 | #define FILE_ERRORDEFINES_H_SEEN
45 |
46 |
47 | /** @todo TODO Introduce some structure to the numbering such that they can be interpreted somewhat without a chart */
48 |
49 | // A OK Nothing is wrong No error error.
50 | #define NO_PROBLEMO 0x0666
51 |
52 | /* Unconfigured options */
53 | #define IAT_NOT_CONFIGURED_CODE 0x1000
54 | #define CHT_NOT_CONFIGURED_CODE 0x1001
55 | #define TPS_NOT_CONFIGURED_CODE 0x1002
56 | #define EGO_NOT_CONFIGURED_CODE 0x1003
57 | #define BRV_NOT_CONFIGURED_CODE 0x1004
58 | #define MAP_NOT_CONFIGURED_CODE 0x1005
59 | #define AAP_NOT_CONFIGURED_CODE 0x1006
60 | #define MAT_NOT_CONFIGURED_CODE 0x1007
61 | #define EGO2_NOT_CONFIGURED_CODE 0x1008
62 | #define IAP_NOT_CONFIGURED_CODE 0x1009
63 | #define LOAD_NOT_CONFIGURED_CODE 0x100A
64 | #define AIRFLOW_NOT_CONFIGURED_CODE 0x100B
65 | #define BPW_NOT_CONFIGURED_CODE 0x100C
66 |
67 |
68 | /* Badly configured options */
69 | #define VE_TABLE_MAIN_LOAD_LENGTH_TOO_LONG 0x2000
70 | #define VE_TABLE_MAIN_RPM_LENGTH_TOO_LONG 0x2001
71 | #define VE_TABLE_MAIN_MAIN_LENGTH_TOO_LONG 0x2002
72 | #define BRV_MAX_TOO_LARGE 0x2003
73 |
74 |
75 | /* Flash burning error codes */
76 | #define sizeNotMultipleOfSectorSize 0x3000
77 | #define sizeOfBlockToBurnIsZero 0x3001
78 | #define smallBlockCrossesSectorBoundary 0x3002
79 | #define addressNotSectorAligned 0x3003
80 | #define addressNotWordAligned 0x3004
81 | #define addressNotFlashRegion 0x3005
82 | #define flashEraseFailed 0x3006
83 | #define flashAccessError 0x3007
84 | #define flashProtectionError 0x3008
85 |
86 |
87 | // memory check error
88 | #define MEMORY_WRITE_ERROR 0x3009
89 |
90 | /* Communications error codes */
91 | #define unimplementedFunction 0x4000
92 | #define packetChecksumMismatch 0x4001
93 | #define packetTooShortForSpecifiedFields 0x4002
94 | #define doesNotMakeSenseToRetrievePartially 0x4003
95 | #define payloadLengthTypeMismatch 0x4004
96 | #define payloadLengthHeaderMismatch 0x4005
97 | #define invalidPayloadID 0x4006
98 | #define unrecognisedPayloadID 0x4007
99 | #define invalidMemoryActionForID 0x4008
100 | #define invalidIDForMainTableAction 0x4009
101 | #define invalidIDForTwoDTableAction 0x400A
102 | #define noSuchAsyncDatalogType 0x400B
103 | #define datalogLengthExceedsMax 0x400C
104 | #define locationIDNotFound 0x400D
105 | #define requestedRAMPageInvalid 0x400E
106 | #define requestedFlashPageInvalid 0x400F
107 | #define requestedLengthTooLarge 0x4010
108 | #define requestedAddressDisallowed 0x4011
109 | #define invalidSizeOffsetCombination 0x4012
110 | #define uncheckedTableManipulationNotAllowed 0x4013
111 | #define payloadShorterThanSpecifiedValue 0x4014
112 | #define noSuchLocationIDListType 0x4015
113 |
114 | #define invalidAxisOrder 0 /* prevent parsing */
115 | #define invalidAxisIndex 1 /* prevent parsing */
116 |
117 | #define errorBaseMainTableRPM 0x6000
118 | #define invalidMainTableRPMOrder 0x6000
119 | #define invalidMainTableRPMIndex 0x6001
120 | #define invalidMainTableRPMLength 0x6002
121 | #define errorBaseMainTableLoad 0x6003
122 | #define invalidMainTableLoadOrder 0x6003
123 | #define invalidMainTableLoadIndex 0x6004
124 | #define invalidMainTableLoadLength 0x6005
125 | #define invalidMainTableMainLength 0x6006
126 |
127 | #define errorBaseTwoDTableAxis 0x6010
128 | #define invalidTwoDTableAxisOrder 0x6010
129 | #define invalidTwoDTableIndex 0x6011
130 |
131 |
132 | #else
133 | /* let us know if we are being untidy with headers */
134 | #warning "Header file ERRORDEFINES_H seen before, sort it out!"
135 | /* end of the wrapper ifdef from the very top */
136 | #endif
137 |
--------------------------------------------------------------------------------
/src/inc/decoderInterface.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file decoderInterface.h
28 | * @ingroup allHeaders
29 | *
30 | * @brief Objects through which a decoder communicates.
31 | *
32 | * This file contains the declarations of objects used as a common interface
33 | * between all of the different wheel decoders and the main loop scheduler.
34 | *
35 | * @author Fred Cooke
36 | */
37 |
38 |
39 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
40 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
41 | #ifndef FILE_DECODER_INTERFACE_H_SEEN
42 | #define FILE_DECODER_INTERFACE_H_SEEN
43 |
44 |
45 | /**
46 | * RPM Calculations:
47 | *
48 | * Either need a per decoder function that is called from the main loop OR...
49 | * RPM calculation is done in real time inside one of the RPM interrupts OR...
50 | * The choice of either, up to the decoder to decide how it is done, in this
51 | * case the function can either do nothing, or swap some pointers/var values
52 | * around or similar.
53 | *
54 | * MAP Sampling:
55 | *
56 | * Max number of samples = max number of cylinders, has to be handled by decoder due to
57 | * potential mismatch between wheel pattern and cylinder firing pattern.
58 | *
59 | * Scheduling:
60 | *
61 | * Fueling pins could be expected to fire once per cylinder event (1 - 12), or
62 | * once per engine cycle, or something in between, but what is a reasonable
63 | * max, and is it workable to allow some cases and not others?
64 | *
65 | * Ignition pins will only need to be fired once per cycle or twice per cycle,
66 | * unless multi-spark startup is required, however this could be done with
67 | * cascaded dwell events, timer self-set:
68 | *
69 | * on dwell off spark on dwell off spark on dwell off and disable spark
70 | *
71 | * This example is for triple spark, 2 or more than 3 are also possible.
72 | *
73 | * OLD notes:
74 | *
75 | * arrays of output channels, iterate and check for wheel event number, if matched, fire:
76 | * doesn't allow for firing a pin more than once a cycle!! no use.
77 | * allows multi channel on a single wheel event (virtually useless) but is slow, one loop
78 | * and array per type of output channel.
79 | *
80 | * array of wheel events, do lookup for wheel event, then if output channel valid, schedule it.
81 | * single channel per tooth event (acceptable, wire in parallel if required), fast, memory hog,
82 | * need one array per type of channel, array length = max expected tooth count! do we need to
83 | * support every single tooth on a nissan 360 style decoder or just cyl event count, what about
84 | * porsche 130? next stop is 60, seems good. can we use bit-fields to save memory, 1 bit =
85 | * 2 possible pins, 2 bits = 4, etc, this will be slower, though. probably just an unsigned char[]
86 | */
87 |
88 |
89 | // TODO @todo the below vars are just drafts so far, nothing is used, except the RPM stuff which I migrated here from the main header. More work to come.
90 | #define numberOfWheelEvents 1 // not teeth, teeth is misleading - could be leading or trailing edge or both
91 | unsigned char currentWheelEvent; // Current or last wheel event index.
92 | unsigned long wheelEventTimeStamps[numberOfWheelEvents]; // For logging wheel patterns as observed. LOTS of memory :-/ may not be possible except by sending lastStamp rapidly at low RPM
93 | unsigned short* RPM; // final output variable, probably move into inputVars struct?
94 | unsigned short* RPMRecord; // intermediate storage variable, do something with this?
95 | unsigned char ignitionEvents[6];
96 | unsigned char injectionEvents[12];
97 | unsigned char ADCSampleEvents[12]; // ???
98 | unsigned char stagedInjectionEvents; // ???
99 | unsigned char chickenCookerEvents; // ???
100 |
101 |
102 | // Init routine:
103 | //
104 | // Allow configuration of timer details? tick size? If so, need to introduce scaling to calcs to
105 | // produce correct tick count and therefore pulsewidth. Migrate dead time to time units and scale
106 | // to get ticks to add to final pw.
107 | //
108 | // We require some configuration to allow the Nissan style decoder to use the pulse accumulators to
109 | // count those one degree slots accurately to a high rpm without excessive cpu load.
110 |
111 |
112 | // move the following to fuel calcs or sched code header, it doesn't belong here...
113 | //
114 | // stuff to do with timing and sync etc. ie, figuring out upon which
115 |
116 |
117 |
118 | #else
119 | /* let us know if we are being untidy with headers */
120 | #warning "Header file DECODER_INTERFACE_H seen before, sort it out!"
121 | /* end of the wrapper ifdef from the very top */
122 | #endif
123 |
--------------------------------------------------------------------------------
/src/derivedVarsGenerator.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009, 2010 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file derivedVarsGenerator.c
28 | * @ingroup measurementsAndCalculations
29 | *
30 | * @brief Generate the derived variables.
31 | *
32 | * Second level variables are derived from the core variables and generated here.
33 | *
34 | * @author Fred Cooke
35 | */
36 |
37 |
38 | #define DERIVEDVARSGENERATOR_C
39 | #include "inc/FreeMS2.h"
40 | #include "inc/commsCore.h"
41 | #include "inc/tableLookup.h"
42 | #include "inc/derivedVarsGenerator.h"
43 |
44 |
45 | /** @brief Generate the derived variables.
46 | *
47 | * This function uses the core variables to lookup and calculate further second
48 | * order variables such as load, VE, Lamdda, Transient fuel correction, engine
49 | * temperature enrichment, Injector dead time, etc.
50 | *
51 | * @author Fred Cooke
52 | */
53 | //void generateDerivedVars(){
54 | // /*&&&&&&&&&&&&&&&&&&&& Use basic variables to lookup and calculate derived variables &&&&&&&&&&&&&&&&&&&*/
55 | //
56 | //
57 | // /* Determine load based on options */
58 | // if(TRUE){ /* Use MAP as load */
59 | // DerivedVars->LoadMain = CoreVars->MAP;
60 | // }else if(FALSE){ /* Use TPS as load */
61 | // DerivedVars->LoadMain = CoreVars->TPS;
62 | // }else if(FALSE){ /* Use AAP corrected MAP as load */
63 | // DerivedVars->LoadMain = ((unsigned long)CoreVars->MAP * CoreVars->AAP) / seaLevelKPa;
64 | // }else{ /* Default to MAP, but throw error */
65 | // DerivedVars->LoadMain = CoreVars->MAP;
66 | // /* If anyone is listening, let them know something is wrong */
67 | // sendErrorIfClear(LOAD_NOT_CONFIGURED_CODE); // or maybe queue it?
68 | // }
69 | //
70 | //
71 | // /* Look up VE with RPM and Load */
72 | // DerivedVars->VEMain = lookupPagedMainTableCellValue((mainTable*)&TablesA.VETableMain, CoreVars->RPM, DerivedVars->LoadMain, currentFuelRPage);
73 | //
74 | //
75 | // /* Look up target Lambda with RPM and Load */
76 | // DerivedVars->Lambda = lookupPagedMainTableCellValue((mainTable*)&TablesD.LambdaTable, CoreVars->RPM, DerivedVars->LoadMain, currentFuelRPage);
77 | //
78 | //
79 | // /* Look up injector dead time with battery voltage */
80 | // DerivedVars->IDT = lookupTwoDTableUS((twoDTableUS*)&TablesA.SmallTablesA.injectorDeadTimeTable, CoreVars->BRV);
81 | //
82 | //
83 | // /* Look up the engine temperature enrichment percentage with temperature */
84 | // DerivedVars->ETE = lookupTwoDTableUS((twoDTableUS*)&TablesA.SmallTablesA.engineTempEnrichmentTablePercent, CoreVars->CHT);
85 | // /* TODO The above needs some careful thought put into it around different loads and correction effects. */
86 | //
87 | //
88 | // /* Calculate the Transient Fuel Correction */
89 | // if(TRUE /*WWTFC*/){ /* Do ONLY WW correction if enabled */
90 | // // Do ww stuff, maybe pre done via RTC/RTI for consistent period?
91 | // DerivedVars->TFCTotal = 0; /* TODO replace with real code */
92 | // }else if(FALSE /*STDTFC*/){ /* Do any combination of standard approximate methods */
93 | // /* Initialse the variable as a base */
94 | // DerivedVars->TFCTotal = 0;
95 | // /* Based on the rate of change of MAP and some history/taper time */
96 | // if(FALSE /*MAPTFC*/){
97 | // // Do MAP based
98 | // DerivedVars->TFCTotal += 0;
99 | // }
100 | //
101 | // /* Based on the rate of change of TPS and some history/taper time */
102 | // if(FALSE /*TPSTFC*/){
103 | // // Do TPS based
104 | // DerivedVars->TFCTotal += 0;
105 | // }
106 | //
107 | // /* Based on the rate of change of RPM and some history/taper time */
108 | // if(FALSE /*RPMTFC*/){
109 | // // Do RPM based
110 | // DerivedVars->TFCTotal += 0;
111 | // }
112 | // }else{ /* Default to no correction */
113 | // DerivedVars->TFCTotal = 0;
114 | // /* Don't throw error as correction may not be required */
115 | // }
116 | //
117 | // // debug
118 | //
119 | // LongTime breakout2, breakout4;
120 | //// breakout.timeLong = timeBetweenSuccessivePrimaryPulsesBuffer;
121 | // breakout2.timeLong = timeBetweenSuccessivePrimaryPulses;
122 | //// breakout3.timeLong = lengthOfSecondaryHighPulses;
123 | // breakout4.timeLong = lengthOfSecondaryLowPulses;
124 | //
125 | //// DerivedVars->sp1 = Counters.primaryTeethSeen;
126 | //// DerivedVars->sp2 = Counters.secondaryTeethSeen;
127 | //
128 | //// DerivedVars->sp3 = breakout4.timeShorts[0];
129 | // DerivedVars->sp1 = breakout4.timeShorts[1];
130 | //
131 | //// DerivedVars->TFCTotal = *RPMRecord;
132 | //
133 | //// CoreVars->DMAP = breakout3.timeShorts[0];
134 | //// CoreVars->DTPS = breakout3.timeShorts[1];
135 | //
136 | // CoreVars->DRPM = breakout2.timeShorts[0];
137 | // CoreVars->DDRPM = breakout2.timeShorts[1];
138 | //
139 | // /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
140 | //}
141 |
--------------------------------------------------------------------------------
/src/inc/interrupts.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009, 2010 Fred Cooke, Jared Harvey
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file interrupts.h
28 | * @ingroup allHeaders
29 | * @ingroup globalHeaders
30 | *
31 | * @brief All interrupt handler declarations
32 | *
33 | * All of the declarations for ISR functions are done here because they are all
34 | * used in one place and it doesn't make sense to spread them out over N files
35 | * for N functions. ISR headers only exist where there is a requirement for
36 | * local variables and constants etc.
37 | *
38 | * @author Fred Cooke
39 | */
40 |
41 |
42 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
43 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
44 | #ifndef FILE_INTERRUPTS_H_SEEN
45 | #define FILE_INTERRUPTS_H_SEEN
46 |
47 |
48 | /* http://www.gnu.org/software/m68hc11/m68hc11_gcc.html Section 1.4.1 */
49 | /* http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html */
50 | /* http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Variable-Attributes.html */
51 |
52 | /* Interrupt attribute shortcut */
53 | #define INT __attribute__((interrupt))
54 |
55 | /* Start and stop atomic operations (Things that we don't want interrupted half way through) */
56 | /* For certain operations we will need to prevent the process from being interrupted, operations such as */
57 | /* writing all vars to a block ready for reading and logging etc. The link below is for avrs, but goes */
58 | /* into some detail about clearing and setting interrupts during important operations. */
59 | /* http://hubbard.engr.scu.edu/embedded/avr/doc/avr-libc/avr-libc-user-manual/group__avr__interrupts.html */
60 | #define ATOMIC_START() __asm__ __volatile__ ("sei") /* set global interrupt mask */
61 | #define ATOMIC_END() __asm__ __volatile__ ("cli") /* clear global interrupt mask */
62 |
63 | /* Interrupt vector memory management */
64 | #define VECTORS __attribute__ ((section (".vectors")))
65 | extern void _start(void);
66 |
67 | /* Interrupt sub-routine prototypes - assigned to text1 region in linear space */
68 | void UISR(void) INT TEXT1; /* Unimplemented Interrupt Sub Routine */
69 | /** @brief Injector1ISR is expanded from InjectorXISR via include statement, and macro definition(s) */
70 | void Injector1ISR(void) INT TEXT1; /* OC timer for injector channel 1 */
71 | /** @brief Injector2ISR is expanded from InjectorXISR via include statement, and macro definition(s) */
72 | void Injector2ISR(void) INT TEXT1; /* OC timer for injector channel 2 */
73 | /** @brief Injector3ISR is expanded from InjectorXISR via include statement, and macro definition(s) */
74 | void Injector3ISR(void) INT TEXT1; /* OC timer for injector channel 3 */
75 | /** @brief Injector4ISR is expanded from InjectorXISR via include statement, and macro definition(s) */
76 | void Injector4ISR(void) INT TEXT1; /* OC timer for injector channel 4 */
77 | /** @brief Injector5ISR is expanded from InjectorXISR via include statement, and macro definition(s) */
78 | void Injector5ISR(void) INT TEXT1; /* OC timer for injector channel 5 */
79 | /** @brief Injector6ISR is expanded from InjectorXISR via include statement, and macro definition(s) */
80 | void Injector6ISR(void) INT TEXT1; /* OC timer for injector channel 6 */
81 |
82 | void PrimaryRPMISR(void) INT TEXT1; /* IC timer for primary engine position and RPM */
83 | void SecondaryRPMISR(void) INT TEXT1; /* IC timer for secondary engine position and RPM */
84 |
85 | void TimerOverflow(void) INT TEXT1; /* IC/OC timer overflow handling */
86 | void ModDownCtrISR(void) INT TEXT1; /* Modulus Down Counter */
87 |
88 | void IgnitionDwellISR(void) INT TEXT1; /* PIT timer 0 for dwell start */
89 | void IgnitionFireISR(void) INT TEXT1; /* PIT timer 1 for coil firing */
90 | void StagedOnISR(void) INT TEXT1; /* PIT timer 2 for switching staged injectors on */
91 | void StagedOffISR(void) INT TEXT1; /* PIT timer 3 for switching staged injectors off */
92 |
93 | void PortPISR(void) INT TEXT1; /* Port P interrupt service routine */
94 | void PortHISR(void) INT TEXT1; /* Port P interrupt service routine */
95 | void PortJISR(void) INT TEXT1; /* Port P interrupt service routine */
96 |
97 | void IRQISR(void) INT TEXT1; /* IRQ/PE1 interrupt service routine */
98 | void XIRQISR(void) INT TEXT1; /* XIRQ/PE0 interrupt service routine */
99 |
100 | void RTIISR(void) INT TEXT1; /* Real Time interrupt service routine */
101 |
102 | void SCI0ISR(void) INT TEXT1; /* Serial 0 interrupt service routine */
103 |
104 | void LowVoltageISR(void) INT TEXT1; /* Low voltage counter ISR */
105 | void VRegAPIISR(void) INT TEXT1; /* VReg periodic interrupt ISR */
106 |
107 | typedef void (* interruptTable)(void);
108 |
109 |
110 | #else
111 | /* let us know if we are being untidy with headers */
112 | #warning "Header file INTERRUPTS_H seen before, sort it out!"
113 | /* end of the wrapper ifdef from the very top */
114 | #endif
115 |
--------------------------------------------------------------------------------
/src/realtimeISRs.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file realtimeISRs.c
28 | * @ingroup interruptHandlers
29 | *
30 | * @brief Real time interrupts
31 | *
32 | * This file contains real time interrupt handlers. Mainly it holds the RTI
33 | * handler itself, however the modulus down counter and ETC timer overflow
34 | * functions are here too.
35 | *
36 | * @author Fred Cooke
37 | */
38 |
39 |
40 | #define REALTIMEISRS_C
41 | #include "inc/FreeMS2.h"
42 | #include "inc/interrupts.h"
43 | #include "inc/commsISRs.h"
44 |
45 |
46 | /** @brief Real Time Interrupt Handler
47 | *
48 | * Handles time keeping, including all internal clocks, and generic periodic
49 | * tasks that run quickly and must be done on time.
50 | *
51 | * @author Fred Cooke
52 | */
53 | void RTIISR(){
54 | /* Clear the RTI flag */
55 | CRGFLG = 0x80;
56 |
57 | /* Record time stamp for code run time reporting */
58 | unsigned short startTimeRTI = TCNT;
59 |
60 | /* Increment the counter */
61 | Clocks.realTimeClockMain++;
62 |
63 | /* This function could be performed without the extra variables by rolling over the main ones at the largest multiples of the next ones, but I'm not sure thats better */
64 |
65 | // TODO add content to eighths of a milli RTC ?
66 |
67 | /* Every 8th RTI execution is one milli */
68 | if(Clocks.realTimeClockMain % 8 == 0){
69 | /* Increment the milli counter */
70 | Clocks.realTimeClockMillis++;
71 |
72 | /* Increment the milli roll over variable */
73 | Clocks.millisToTenths++;
74 |
75 | /* Perform all tasks that are once per millisecond here or preferably main */
76 | Clocks.timeoutADCreadingClock++;
77 | if(Clocks.timeoutADCreadingClock > fixedConfigs2.sensorSettings.readingTimeout){
78 | /* Set force read adc flag */
79 | coreStatusA |= FORCE_READING;
80 | Clocks.timeoutADCreadingClock = 0;
81 | }
82 |
83 | /* Every 100 millis is one tenth */
84 | if(Clocks.millisToTenths % 100 == 0){
85 | /* Increment the tenths counter */
86 | Clocks.realTimeClockTenths++;
87 |
88 | /* Increment the tenths roll over variable */
89 | Clocks.tenthsToSeconds++;
90 |
91 | /* Reset the millis roll over variable */
92 | Clocks.millisToTenths = 0;
93 |
94 | /* Perform all tasks that are once per tenth of a second here or preferably main */
95 | // decrement port H debounce variable till it's zero again.
96 | if(portHDebounce != 0){
97 | portHDebounce -= 1;
98 | }
99 |
100 | /* Every 10 tenths is one second */
101 | if(Clocks.tenthsToSeconds % 10 == 0){
102 | /* Increment the seconds counter */
103 | Clocks.realTimeClockSeconds++;
104 |
105 | // fuel pump flasher
106 | PORTE ^= BIT4;
107 |
108 | if(PORTM){
109 | PORTM = 0x00;
110 | }else{
111 | PORTM = 0xFF;
112 | }
113 | /* Increment the seconds roll over variable */
114 | Clocks.secondsToMinutes++;
115 |
116 | /* Reset the tenths roll over variable */
117 | Clocks.tenthsToSeconds = 0;
118 | /* Perform all tasks that are once per second here or preferably main */
119 |
120 | // temp throttling for log due to tuner performance issues (in the bedroom)
121 | ShouldSendLog = TRUE;
122 | /* Flash the user LED as a "heartbeat" to let new users know it's alive */
123 | //PORTP ^= 0x80;
124 |
125 | /* Every 60 seconds is one minute, 65535 minutes is enough for us :-) */
126 | if(Clocks.secondsToMinutes % 60 == 0){
127 | /* Increment the minutes counter */
128 | Clocks.realTimeClockMinutes++;
129 |
130 | /* Potentially put an hours field in here and below, but that would be excessive */
131 | // TODO add hours RTC ?
132 |
133 | /* Reset the seconds roll over variable */
134 | Clocks.secondsToMinutes = 0;
135 |
136 | /* Perform all tasks that are once per minute here or preferably main */
137 | // TODO add content in minutes RTC ?
138 |
139 | /* Hours if statement here if we do hours which we probably won't */
140 | }
141 | }
142 | }
143 | }
144 | RuntimeVars.RTCRuntime = TCNT - startTimeRTI;
145 | }
146 |
147 |
148 | /** @brief ECT overflow handler
149 | *
150 | * When the ECT free running timer hits 65535 and rolls over, this is run. Its
151 | * job is to extend the timer to an effective 32 bits for longer measuring much
152 | * longer periods with the same resolution.
153 | *
154 | * @author Fred Cooke
155 | */
156 | void TimerOverflow(){
157 | /* Increment the timer extension variable */
158 | timerExtensionClock++;
159 |
160 | /* Clear the timer overflow interrupt flag */
161 | TFLGOF = 0x80;
162 | }
163 |
164 |
165 | /** @todo TODO This could be useful in future once sleeping is implemented.
166 | // Generic periodic interrupt (This only works from wait mode...)
167 | void VRegAPIISR(){
168 | // Clear the flag needs check because writing a 1 can set this one
169 | //if(VREGAPICL & 0x01){ // if the flag is set...
170 | VREGAPICL |= 0x01; // clear it...
171 | //} // and not otherwise!
172 |
173 | // DO stuff
174 | }
175 | */
176 |
--------------------------------------------------------------------------------
/src/inc/commsCore.h:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009 Fred Cooke
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file commsCore.h
28 | * @ingroup allHeaders
29 | */
30 |
31 |
32 | /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 | /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 | #ifndef FILE_COMMS_CORE_H_SEEN
35 | #define FILE_COMMS_CORE_H_SEEN
36 |
37 |
38 | #ifdef EXTERN
39 | #warning "EXTERN already defined by another header, please sort it out!"
40 | #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 | #endif
42 |
43 |
44 | #ifdef COMMSCORE_C
45 | #define EXTERN
46 | /* Internal use without check on buffer, purely here to place functions in paged memory. */
47 | void sendErrorInternal(unsigned short) FPAGE_FE;
48 | void sendDebugInternal(unsigned char*) FPAGE_FE;
49 | #else
50 | #define EXTERN extern
51 | #endif
52 |
53 |
54 | /* Function declarations */
55 | /* This function accesses paged flash and thus must be in linear space. Set explicitly to text. */
56 | EXTERN void decodePacketAndRespond(void) TEXT;
57 |
58 | EXTERN void sendErrorIfClear(unsigned short) FPAGE_FE;
59 | EXTERN void sendDebugIfClear(unsigned char*) FPAGE_FE;
60 | //EXTERN void sendErrorBusyWait(unsigned short) FPAGE_FE;
61 | //EXTERN void sendDebugBusyWait(unsigned char*) FPAGE_FE;
62 |
63 | EXTERN void resetReceiveState(unsigned char) FPAGE_FE;
64 | EXTERN void finaliseAndSend(unsigned short) FPAGE_FE;
65 |
66 | EXTERN void populateBasicDatalog(void) FPAGE_FE;
67 |
68 |
69 | /* Global variables for TX (one set per interface) */
70 | //EXTERN unsigned short TXPacketLengthToSendCAN0;
71 | EXTERN unsigned short TXPacketLengthToSendSCI0;
72 | //EXTERN unsigned char* TXBufferCurrentPositionHandler;
73 | //EXTERN unsigned char* TXBufferCurrentPositionCAN0;
74 | EXTERN unsigned char* TXBufferCurrentPositionSCI0;
75 |
76 |
77 | /* Buffer use and source IDs/flags */
78 | //EXTERN unsigned char TXBufferInUseFlags;
79 | EXTERN unsigned char RXBufferContentSourceID;
80 | /* Masks for TXBufferInUseFlags and RXBufferContentSourceID */
81 | #define COM_SET_SCI0_INTERFACE_ID BIT0
82 | #define COM_SET_CAN0_INTERFACE_ID BIT1
83 | #define COM_SET_SPARE2_INTERFACE_ID BIT2
84 | #define COM_SET_SPARE3_INTERFACE_ID BIT3
85 | #define COM_SET_SPARE4_INTERFACE_ID BIT4
86 | #define COM_SET_SPARE5_INTERFACE_ID BIT5
87 | #define COM_SET_SPARE6_INTERFACE_ID BIT6
88 | #define COM_SET_SPARE7_INTERFACE_ID BIT7
89 | #define COM_CLEAR_SCI0_INTERFACE_ID NBIT0
90 | #define COM_CLEAR_CAN0_INTERFACE_ID NBIT1
91 | #define COM_CLEAR_SPARE2_INTERFACE_ID NBIT2
92 | #define COM_CLEAR_SPARE3_INTERFACE_ID NBIT3
93 | #define COM_CLEAR_SPARE4_INTERFACE_ID NBIT4
94 | #define COM_CLEAR_SPARE5_INTERFACE_ID NBIT5
95 | #define COM_CLEAR_SPARE6_INTERFACE_ID NBIT6
96 | #define COM_CLEAR_SPARE7_INTERFACE_ID NBIT7
97 | #define CLEAR_ALL_SOURCE_ID_FLAGS ZEROS
98 |
99 |
100 | /* Global variables for RX (one set for all) */
101 | EXTERN unsigned char RXStateFlags;
102 | EXTERN unsigned char* RXBufferCurrentPosition;
103 | EXTERN unsigned short RXPacketLengthReceived;
104 | EXTERN unsigned short RXCalculatedPayloadLength; // why global??
105 | /* Masks for SCIRXStateFlags */
106 | //#define RX_BUFFER_IN_USE BIT0
107 | #define RX_READY_TO_PROCESS BIT1
108 | #define RX_SCI_ESCAPED_NEXT BIT2
109 | //#define RX_SCI_INSIDE_PACKET BIT3
110 | //#define RX_BUFFER_NOT_IN_USE NBIT0
111 | #define RX_CLEAR_READY_TO_PROCESS NBIT1
112 | #define RX_SCI_NOT_ESCAPED_NEXT NBIT2
113 | //#define RX_SCI_NOT_INSIDE_PACKET NBIT3
114 |
115 | /* Global CAN specific variables */
116 | // TODO can id filters routing etc
117 |
118 |
119 | /* Comms Control Enable and Disable Masks */
120 | /* SCI masks */
121 | #define SCICR2_RX_ENABLE BIT2
122 | #define SCICR2_TX_ENABLE BIT3
123 | #define SCICR2_RX_ISR_ENABLE BIT5
124 | #define SCICR2_TX_ISR_ENABLE BIT7
125 | #define SCICR2_RX_DISABLE NBIT2
126 | #define SCICR2_TX_DISABLE NBIT3
127 | #define SCICR2_RX_ISR_DISABLE NBIT5
128 | #define SCICR2_TX_ISR_DISABLE NBIT7
129 | /* CAN masks */
130 | // TODO probably 8 of these too
131 | // TODO probably 8 of these too
132 | // TODO probably 8 of these too
133 | // TODO probably 8 of these too
134 | // TODO probably 8 of these too
135 | // TODO probably 8 of these too
136 | // TODO probably 8 of these too
137 | // TODO probably 8 of these too
138 |
139 |
140 |
141 | /* Header components */
142 | EXTERN unsigned char RXHeaderFlags;
143 | EXTERN unsigned short RXHeaderPayloadID; /// TODO @todo why global?
144 | EXTERN unsigned short RXHeaderPayloadLength;
145 |
146 |
147 | /* Header flag masks */
148 | /* Always has flags (obviously) */
149 | /* Always has payload ID so no flag */
150 | /* Always has checksum, so no flag */
151 | #define HEADER_HAS_LENGTH BIT0
152 | #define HEADER_IS_NACK BIT1
153 | #define HEADER_HAS_SEQUENCE BIT2
154 | #define HEADER_RESERVED_E BIT3
155 | #define HEADER_RESERVED_D BIT4
156 | #define HEADER_RESERVED_C BIT5
157 | #define HEADER_RESERVED_B BIT6
158 | #define HEADER_RESERVED_A BIT7
159 |
160 |
161 | #include "packetTypes.h"
162 |
163 |
164 | #undef EXTERN
165 |
166 |
167 | #else
168 | /* let us know if we are being untidy with headers */
169 | #warning "Header file COMMS_CORE_H seen before, sort it out!"
170 | /* end of the wrapper ifdef from the very top */
171 | #endif
172 |
--------------------------------------------------------------------------------
/lib/FreeMS2-SerialMonitor-1.0.s19:
--------------------------------------------------------------------------------
1 | S042000053657269616C206D6F6E69746F722072697070656420616E642066696E6765727072696E7465642062792074686520556C74696D617465204C6F616465722154
2 | S0210000446174653A20202020202020202020202020202030352F30322F323031335B
3 | S01B000056657273696F6E3A2020202020202020202020203032303280
4 | S01D0000436C61696D6564206465766963652049443A20203078333130330D
5 | S21400F800180B000011180B3900104F1C3005180B90
6 | S21400F81009001287F6F7FE5127231C025C201C0203
7 | S21400F8204D011C024C01C70431FDF60258C52027C5
8 | S21400F8300C1D024D011D024C0105FBFFC11D025CA3
9 | S21400F840204D39804C3A40180B020034180B00004B
10 | S21400F85035A7A74F3708FC4C3980180B270100182E
11 | S21400F8600B270110CF4000FEF7FE34CE00003434E4
12 | S21400F87034C6D037180B0D00C9180B0C00CB9727D1
13 | S21400F8800986E316FC87860C202F4FCC80FC4CCBD9
14 | S21400F89001CE05DC8E00000435FA4DCB0116FC7E49
15 | S21400F8A0810D26F986E016FC878608200C86E01671
16 | S21400F8B0FC8796CA840844444416FC87863E16FC99
17 | S21400F8C0874FCA080A4FCA20034C204006FC63161E
18 | S21400F8D0FC7ECEF8E8A100270B1A038EF92D26F53C
19 | S21400F8E086E120CBEE010500A1FAF6A2FB81A3FB80
20 | S21400F8F001A4FB9BA5FB6CA6FBA3A7FB11A8FB28FA
21 | S21400F900A9FBC1AAFC18ABFC10ACFC08ADFC00AE11
22 | S21400F910FBF2AFFBEAB1FC63B2FC3BB3F941B4F9CE
23 | S21400F9207DB6F9EEB7F92DB8FAA7B9F9BC86DC169C
24 | S21400F930FC87961A16FC87961B16FC8786E006F848
25 | S21400F940AF4DCA0886E016FC87860206F8B94F2037
26 | S21400F95040064CCA204D20401C025C204CCA08C6FB
27 | S21400F96001C1012611F60258C520270AFDF7D68DDB
28 | S21400F970FFFF270205401D025C2006F8CF86415A8D
29 | S21400F9803C913C270306F800141020FE79002879E5
30 | S21400F99000204DCA08C6048F301B25188F3FF8225A
31 | S21400F9A01386E016FC87180F4FCA04054DCA048656
32 | S21400F9B00406F8B986E306F8644DCA2016FD2F4FF4
33 | S21400F9C01C3026CD00006C40180B410116180B8029
34 | S21400F9D00115A7A7A7B601152AFB482AF8B6010500
35 | S21400F9E08430260586E006F8AF86E906F8AF16FDF1
36 | S21400F9F02F4F1C301ACD00006C40180B4101161812
37 | S21400FA000B800115A7A7A7B601152AFB482AF8D62A
38 | S21400FA103037C608536BAF863F18165A3079010345
39 | S21400FA20CE0400CC40001810B754CE8000075E729B
40 | S21400FA300030638026EACE0400CC38001810B75495
41 | S21400FA40CE8000074833C60153271FC6385B3054A4
42 | S21400FA5054CD04008D020027015451C4037B0103DA
43 | S21400FA60070ED630CB08C1372BE3335B3006F8AD34
44 | S21400FA7034CE80006A00180B410106180B80010581
45 | S21400FA80A7A7A7B601052AFB482AF8303DB7966C0B
46 | S21400FA9000180B40010616FD9E9726081AE2040081
47 | S21400FAA00436EC3D3A204A16FD2FD6305454CD0489
48 | S21400FAB0008D020027015451C4037B0103D630C1D8
49 | S21400FAC03F2611CE0400CC38001810B754CE800064
50 | S21400FAD007BB2011CE0400CC40001810B754CE80CF
51 | S21400FAE00007AA2000B601058430260586E006F841
52 | S21400FAF0AF86E606F8AF16FC73A60016FC8706F877
53 | S21400FB00AD16FC73EC0016FC87180F16FC8706F87B
54 | S21400FB10AD16FC7316FC7E180E52A60016FC87085F
55 | S21400FB205326F786E006F8AF16FC7316FC7E180E12
56 | S21400FB3052C10137271BB7508501261516FC7E18C3
57 | S21400FB400E638016FC7EB78116FCBD332617082090
58 | S21400FB500916FC7E16FCDF33260B085326D386E0F8
59 | S21400FB6020C316FC7E5326FA86E620B94FCA080C38
60 | S21400FB708716FC8716FC8786E206F8AF073806FB72
61 | S21400FB800416FC7316FC7E16FC8E270220086A00FC
62 | S21400FB908786E006F8AF86E506F8AF16FC73C60261
63 | S21400FBA03720994FCA080816FC7386E206F8AF0796
64 | S21400FBB005C6023720861B82EE8308086E831B9ECE
65 | S21400FBC03DB7751A0916FC6AEE8716FC6AEE8516AE
66 | S21400FBD0FC6AEE8316FC6AEE81B7C5B781B7C51618
67 | S21400FBE0FC6AA68016FC8706F8AD16FC7E6A8006C0
68 | S21400FBF0F8AD16FC73B7C5B781B7C56E8106F8AD0C
69 | S21400FC0016FC736E8306F8AD16FC736E8506F8ADAB
70 | S21400FC1016FC736E8706F8AD07591A178E301A252C
71 | S21400FC200A8E3FF72205B75706F8AD86E406F8AF0A
72 | S21400FC303D3E3FFC30FC310030FC324CCA04EE87BF
73 | S21400FC400808B7C5C4FE5C2B5C2E45554555C40355
74 | S21400FC508759B7C5EEE2FC33A6005A2A5A2D86808D
75 | S21400FC605A280B4CCB204DCA040BB7C50719180FE2
76 | S21400FC7007153D0709180E0705B781B7C53D4ECCD9
77 | S21400FC80200220FA96CF3D4FCC80FC5ACF3D3B8ECB
78 | S21400FC90400025148EFF8024098EF7802518C6FFA5
79 | S21400FCA03A3D1AE2F800200E4F1C300E8E0000255A
80 | S21400FCB0098E00002204C6013A3DC73A3D343B0790
81 | S21400FCC0CD2B502715AC00274A3BB751C50126055A
82 | S21400FCD0EC008CFFFF3A263B202C6C008720343447
83 | S21400FCE03B07AB2B2E271AA1002728E60052262317
84 | S21400FCF0B751C5012604E601200C180E09A60020FF
85 | S21400FD00056A0087200D07278E40002504072B2054
86 | S21400FD100207033A303D6C0086207A011686807A08
87 | S21400FD200115A7A7A7B6011584C0482AF8483D368E
88 | S21400FD3086307A01157A0105323DDD30353B8E80FE
89 | S21400FD4000250C8EC000250C180B3F00302005182F
90 | S21400FD500B3E0030D630272E5454CD04008D0200C2
91 | S21400FD6027015451C4037B0103C1003A271E6C00CF
92 | S21400FD7086207A010686800743B601058430B721BF
93 | S21400FD80315D30B7123DC6385B3020CC6C00862023
94 | S21400FD907A010616FD9EB721315D30B7123D34CE8E
95 | S21400FDA0FDCCEC3E3B8EFDBA26F8B7758680150076
96 | S21400FDB01BF20012B601058430303D00B721141046
97 | S21400FDC07A0105A7A7A71F010540FBB7123D077ECE
98 | S21400FDD0077C077A07780776077407720770076E3E
99 | S21400FDE0076C076A07680766076407620760075EAE
100 | S21400FDF0075C075A07580756075407520750074E1E
101 | S21400FE00074C074A07480746074407420740073E8D
102 | S21400FE10073C073A07380736073407320730072EFD
103 | S21400FE20072C072A07280726072407220720071E6D
104 | S21400FE30071C071A07180716071407120710070EDD
105 | S21400FE40070C070A0708070607040702070030ED35
106 | S21400FE50E2F9B08DFFFF270205401AE2F9B0B7C5F8
107 | S21400FE6006F997FFFFFFFFFFFFFFFFFFFFFFFFFF04
108 | S21400FE70FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8D
109 | S21400FE80FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7D
110 | S21400FE90FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6D
111 | S21400FEA0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D
112 | S21400FEB0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4D
113 | S21400FEC0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3D
114 | S21400FED0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2D
115 | S21400FEE0FFFFFFFFFFFF06FC8706FC7E06F9EE0617
116 | S21400FEF0FD9E06FCBDFFFFFF310302052013020234
117 | S21400FF00FFFFFFFFFFFFFFFFFFFFFFFFFFC7FFBE75
118 | S21400FF10FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC
119 | S21400FF20FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC
120 | S21400FF30FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFCC
121 | S21400FF40FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBC
122 | S21400FF50FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAC
123 | S21400FF60FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9C
124 | S21400FF70FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8C
125 | S21400FF80FDCEFDD0FDD2FDD4FDD6FDD8FDDAFDDCDC
126 | S21400FF90FDDEFDE0FDE2FDE4FDE6FDE8FDEAFDEC4C
127 | S21400FFA0FDEEFDF0FDF2FDF4FDF6FDF8FDFAFDFCBC
128 | S21400FFB0FDFEFE00FE02FE04FE06FE08FE0AFE0C25
129 | S21400FFC0FE0EFE10FE12FE14FE16FE18FE1AFE1C94
130 | S21400FFD0FE1EFE20FE22F94EFE26FE28FE2AFE2CDF
131 | S21400FFE0FE2EFE30FE32FE34FE36FE38FE3AFE3C74
132 | S21400FFF0FE3EFE40FE42F98CFE46F800FE4AF80041
133 | S50300807C
134 | S9030000FC
135 |
--------------------------------------------------------------------------------
/src/inc/injectorISR.c:
--------------------------------------------------------------------------------
1 | /* FreeMS2 - the open source engine management system
2 | *
3 | * Copyright 2008, 2009, 2010 Fred Cooke, Jared Harvey
4 | *
5 | * This file is part of the FreeMS2 project.
6 | *
7 | * FreeMS2 software is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * FreeMS2 software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with any FreeMS2 software. If not, see http://www.gnu.org/licenses/
19 | *
20 | * We ask that if you make any changes to this file you email them upstream to
21 | * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22 | *
23 | * Thank you for choosing FreeMS2 to run your engine!
24 | */
25 |
26 |
27 | /** @file injectorISR.c
28 | *
29 | * @brief Injector ISR shared code
30 | *
31 | * This code is identical between all 6 channels, and thus we only want one
32 | * copy of it. The X in each macro will be replaced with the number that is
33 | * appropriate for the channel it is being used for at the time.
34 | *
35 | * Each channel performs the following actions
36 | *
37 | * - 1 Clear its interrupt flag
38 | * - 2 Record its start time
39 | * - 3 Measure and record its latency
40 | * - 4 Check to see if its just turned on
41 | * - 4.1 Copy the channels pulse width to a local variable
42 | * - 4.2 Determine the minimum pulse width based on code run time const and latency
43 | * - 4.3 Clamp used pulsewidth inside min and max
44 | * - 4.4 If used pulse width is larger than the current period of the engines cycle flag as always on
45 | * - 4.5 Set the action to turn off
46 | * - 4.6 Increment the time by pulse width
47 | * - 4.7 If staging required, either, switch them on and sched to turn off, or sched to turn on
48 | * - 5 Else it has just turned off
49 | * - 5.1 If staged channel is still on, turn it off
50 | * - 5.2 If(self schedule flagged) schedule the next start
51 | * - 5.3 Else disable itself
52 | * - 6 Calculate and record code run time
53 | * - 7 Return
54 | *
55 | * @author Fred Cooke
56 | */
57 |
58 |
59 | void InjectorXISR(){
60 | /* Clear the interrupt flag for this channel */
61 | TFLG = injectorMainOnMasks[INJECTOR_CHANNEL_NUMBER];
62 |
63 | /* Record the current time as start time */
64 | unsigned short TCNTStart = TCNT;
65 |
66 | /* Record the edge time stamp from the IC register */
67 | unsigned short edgeTimeStamp = *injectorMainTimeRegisters[INJECTOR_CHANNEL_NUMBER];
68 |
69 | /* Calculate and store the latency based on compare time and start time */
70 | injectorCodeLatencies[INJECTOR_CHANNEL_NUMBER] = TCNTStart - edgeTimeStamp;
71 |
72 | /* If rising edge triggered this */
73 | if(PTIT & injectorMainOnMasks[INJECTOR_CHANNEL_NUMBER]){ // Stuff for switch on time
74 |
75 | /* Find out what max and min for pulse width are */
76 | unsigned short localPulseWidth = injectorMainPulseWidthsRealtime[INJECTOR_CHANNEL_NUMBER];
77 | unsigned short localMinimumPulseWidth = injectorSwitchOnCodeTime + injectorCodeLatencies[INJECTOR_CHANNEL_NUMBER];
78 |
79 | /** @todo TODO *maybe* instead of checking min and increasing pulse, just force it straight off if diff between start and now+const is greater than desired pulsewidth */
80 |
81 | /* Ensure we dont go under minimum pulsewidth */
82 | if(localPulseWidth < localMinimumPulseWidth){
83 | localPulseWidth = localMinimumPulseWidth;
84 | }/* else{ just use the value } */
85 |
86 | LongTime timeStamp;
87 |
88 | /* Install the low word */
89 | timeStamp.timeShorts[1] = edgeTimeStamp;
90 | /* Find out what our timer value means and put it in the high word */
91 | if(TFLGOF && !(edgeTimeStamp & 0x8000)){ /* see 10.3.5 paragraph 4 of 68hc11 ref manual for details */
92 | timeStamp.timeShorts[0] = timerExtensionClock + 1;
93 | }else{
94 | timeStamp.timeShorts[0] = timerExtensionClock;
95 | }
96 |
97 | // store the end time for use in the scheduler
98 | injectorMainEndTimes[INJECTOR_CHANNEL_NUMBER] = timeStamp.timeLong + localPulseWidth;
99 |
100 | /* Set the action for compare to switch off FIRST or it might inadvertently PWM the injector during opening... */
101 | *injectorMainControlRegisters[INJECTOR_CHANNEL_NUMBER] &= injectorMainGoLowMasks[INJECTOR_CHANNEL_NUMBER];
102 |
103 | /* Set the time to turn off again */
104 | *injectorMainTimeRegisters[INJECTOR_CHANNEL_NUMBER] += localPulseWidth;
105 |
106 | /* This is the point we actually want the time to, but because the code is so simple, it can't help but be a nice short time */
107 |
108 | /* If staged injection is required, switch on or schedule corresponding staged injector and remember that we did. */
109 | if(coreStatusA & STAGED_REQUIRED){
110 | if(fixedConfigs1.coreSettingsA & STAGED_START){
111 | /* Switch that channel on NOW */
112 | STAGEDPORT |= STAGEDXON;
113 | stagedOn |= STAGEDXON;
114 | }else{
115 | /* Schedule the start at a later time */
116 | /// @todo TODO PIT scheduling of staged start
117 | }
118 | }
119 | /* Calculate and store code run time */
120 | injectorCodeOpenRuntimes[INJECTOR_CHANNEL_NUMBER] = TCNT - TCNTStart;
121 | }else{ // Stuff for switch off time
122 | /* If we switched the staged injector on and it's still on, turn it off now. */
123 | if(stagedOn & STAGEDXON){
124 | STAGEDPORT &= STAGEDXOFF;
125 | stagedOn &= STAGEDXOFF;
126 | }
127 |
128 | /* Set the action for compare to switch on and the time to next start time, clear the self timer flag */
129 | if(selfSetTimer & injectorMainOnMasks[INJECTOR_CHANNEL_NUMBER]){
130 | *injectorMainTimeRegisters[INJECTOR_CHANNEL_NUMBER] = injectorMainStartTimesHolding[INJECTOR_CHANNEL_NUMBER];
131 | *injectorMainControlRegisters[INJECTOR_CHANNEL_NUMBER] |= injectorMainGoHighMasks[INJECTOR_CHANNEL_NUMBER];
132 | selfSetTimer &= injectorMainOffMasks[INJECTOR_CHANNEL_NUMBER];
133 | }else{
134 | // Disable interrupts and actions incase the period from this end to the next start is long (saves cpu)
135 | TIE &= injectorMainOffMasks[INJECTOR_CHANNEL_NUMBER];
136 | *injectorMainControlRegisters[INJECTOR_CHANNEL_NUMBER] &= injectorMainDisableMasks[INJECTOR_CHANNEL_NUMBER];
137 | }
138 | /* Calculate and store code run time */
139 | injectorCodeCloseRuntimes[INJECTOR_CHANNEL_NUMBER] = TCNT - TCNTStart;
140 | }
141 | }
142 |
--------------------------------------------------------------------------------