generators: correctly handle clustered subtypes used in Atmel SAMD21 SVD for important peripherals
Signed-off-by: Ron Evans <ron@hybridgroup.com>
Этот коммит содержится в:
родитель
e2be7ccf76
коммит
f89c695c8c
2 изменённых файлов: 39 добавлений и 12 удалений
|
@ -187,24 +187,24 @@ func initRTC() {
|
||||||
sam.PM.APBAMASK |= sam.PM_APBAMASK_RTC_
|
sam.PM.APBAMASK |= sam.PM_APBAMASK_RTC_
|
||||||
|
|
||||||
// disable RTC
|
// disable RTC
|
||||||
sam.RTC.MODE0.CTRL = 0
|
sam.RTC_MODE0.CTRL = 0
|
||||||
waitForSync()
|
waitForSync()
|
||||||
|
|
||||||
// reset RTC
|
// reset RTC
|
||||||
sam.RTC.MODE0.CTRL |= sam.RTC_MODE0_CTRL_SWRST
|
sam.RTC_MODE0.CTRL |= sam.RTC_MODE0_CTRL_SWRST
|
||||||
waitForSync()
|
waitForSync()
|
||||||
|
|
||||||
// set Mode0 to 32-bit counter (mode 0) with prescaler 1 and GCLK2 is 32KHz/1
|
// set Mode0 to 32-bit counter (mode 0) with prescaler 1 and GCLK2 is 32KHz/1
|
||||||
sam.RTC.MODE0.CTRL = sam.RegValue16((sam.RTC_MODE0_CTRL_MODE_COUNT32 << sam.RTC_MODE0_CTRL_MODE_Pos) |
|
sam.RTC_MODE0.CTRL = sam.RegValue16((sam.RTC_MODE0_CTRL_MODE_COUNT32 << sam.RTC_MODE0_CTRL_MODE_Pos) |
|
||||||
(sam.RTC_MODE0_CTRL_PRESCALER_DIV1 << sam.RTC_MODE0_CTRL_PRESCALER_Pos) |
|
(sam.RTC_MODE0_CTRL_PRESCALER_DIV1 << sam.RTC_MODE0_CTRL_PRESCALER_Pos) |
|
||||||
sam.RTC_MODE0_CTRL_MATCHCLR)
|
sam.RTC_MODE0_CTRL_MATCHCLR)
|
||||||
waitForSync()
|
waitForSync()
|
||||||
|
|
||||||
sam.RTC.MODE0.COMP0 = 0xffffffff
|
sam.RTC_MODE0.COMP0 = 0xffffffff
|
||||||
waitForSync()
|
waitForSync()
|
||||||
|
|
||||||
// re-enable RTC
|
// re-enable RTC
|
||||||
sam.RTC.MODE0.CTRL |= sam.RTC_MODE0_CTRL_ENABLE
|
sam.RTC_MODE0.CTRL |= sam.RTC_MODE0_CTRL_ENABLE
|
||||||
waitForSync()
|
waitForSync()
|
||||||
|
|
||||||
arm.EnableIRQ(sam.IRQ_RTC)
|
arm.EnableIRQ(sam.IRQ_RTC)
|
||||||
|
@ -241,10 +241,10 @@ func sleepTicks(d timeUnit) {
|
||||||
// ticks returns number of microseconds since start.
|
// ticks returns number of microseconds since start.
|
||||||
func ticks() timeUnit {
|
func ticks() timeUnit {
|
||||||
// request read of count
|
// request read of count
|
||||||
sam.RTC.MODE0.READREQ = sam.RTC_MODE0_READREQ_RREQ
|
sam.RTC_MODE0.READREQ = sam.RTC_MODE0_READREQ_RREQ
|
||||||
waitForSync()
|
waitForSync()
|
||||||
|
|
||||||
rtcCounter := uint64(sam.RTC.MODE0.COUNT) * 30 // each counter tick == 30.5us
|
rtcCounter := uint64(sam.RTC_MODE0.COUNT) * 30 // each counter tick == 30.5us
|
||||||
offset := (rtcCounter - timerLastCounter) // change since last measurement
|
offset := (rtcCounter - timerLastCounter) // change since last measurement
|
||||||
timerLastCounter = rtcCounter
|
timerLastCounter = rtcCounter
|
||||||
timestamp += timeUnit(offset) // TODO: not precise
|
timestamp += timeUnit(offset) // TODO: not precise
|
||||||
|
@ -260,16 +260,16 @@ func timerSleep(ticks uint32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// request read of count
|
// request read of count
|
||||||
sam.RTC.MODE0.READREQ = sam.RTC_MODE0_READREQ_RREQ
|
sam.RTC_MODE0.READREQ = sam.RTC_MODE0_READREQ_RREQ
|
||||||
waitForSync()
|
waitForSync()
|
||||||
|
|
||||||
// set compare value
|
// set compare value
|
||||||
cnt := sam.RTC.MODE0.COUNT
|
cnt := sam.RTC_MODE0.COUNT
|
||||||
sam.RTC.MODE0.COMP0 = sam.RegValue(uint32(cnt) + (ticks / 30)) // each counter tick == 30.5us
|
sam.RTC_MODE0.COMP0 = sam.RegValue(uint32(cnt) + (ticks / 30)) // each counter tick == 30.5us
|
||||||
waitForSync()
|
waitForSync()
|
||||||
|
|
||||||
// enable IRQ for CMP0 compare
|
// enable IRQ for CMP0 compare
|
||||||
sam.RTC.MODE0.INTENSET |= sam.RTC_MODE0_INTENSET_CMP0
|
sam.RTC_MODE0.INTENSET |= sam.RTC_MODE0_INTENSET_CMP0
|
||||||
|
|
||||||
for !timerWakeup {
|
for !timerWakeup {
|
||||||
arm.Asm("wfi")
|
arm.Asm("wfi")
|
||||||
|
@ -279,7 +279,7 @@ func timerSleep(ticks uint32) {
|
||||||
//go:export RTC_IRQHandler
|
//go:export RTC_IRQHandler
|
||||||
func handleRTC() {
|
func handleRTC() {
|
||||||
// disable IRQ for CMP0 compare
|
// disable IRQ for CMP0 compare
|
||||||
sam.RTC.MODE0.INTFLAG = sam.RTC_MODE0_INTENSET_CMP0
|
sam.RTC_MODE0.INTFLAG = sam.RTC_MODE0_INTENSET_CMP0
|
||||||
|
|
||||||
timerWakeup = true
|
timerWakeup = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,15 @@ def readSVD(path, sourceURL):
|
||||||
}
|
}
|
||||||
device.peripherals.append(peripheral)
|
device.peripherals.append(peripheral)
|
||||||
peripheralDict[name] = peripheral
|
peripheralDict[name] = peripheral
|
||||||
|
if 'subtypes' in derivedFrom:
|
||||||
|
for subtype in derivedFrom['subtypes']:
|
||||||
|
subp = {
|
||||||
|
'name': name + "_"+subtype['clusterName'],
|
||||||
|
'groupName': subtype['groupName'],
|
||||||
|
'description': subtype['description'],
|
||||||
|
'baseAddress': baseAddress,
|
||||||
|
}
|
||||||
|
device.peripherals.append(subp)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
peripheral = {
|
peripheral = {
|
||||||
|
@ -89,6 +98,7 @@ def readSVD(path, sourceURL):
|
||||||
'description': description,
|
'description': description,
|
||||||
'baseAddress': baseAddress,
|
'baseAddress': baseAddress,
|
||||||
'registers': [],
|
'registers': [],
|
||||||
|
'subtypes': [],
|
||||||
}
|
}
|
||||||
device.peripherals.append(peripheral)
|
device.peripherals.append(peripheral)
|
||||||
peripheralDict[name] = peripheral
|
peripheralDict[name] = peripheral
|
||||||
|
@ -108,6 +118,23 @@ def readSVD(path, sourceURL):
|
||||||
clusterPrefix = clusterName + '_'
|
clusterPrefix = clusterName + '_'
|
||||||
clusterOffset = int(getText(cluster.find('addressOffset')), 0)
|
clusterOffset = int(getText(cluster.find('addressOffset')), 0)
|
||||||
if cluster.find('dim') is None:
|
if cluster.find('dim') is None:
|
||||||
|
if clusterOffset is 0:
|
||||||
|
# make this a separate peripheral
|
||||||
|
cpRegisters = []
|
||||||
|
for regEl in cluster.findall('register'):
|
||||||
|
cpRegisters.extend(parseRegister(groupName, regEl, baseAddress, clusterName+"_"))
|
||||||
|
cpRegisters.sort(key=lambda r: r['address'])
|
||||||
|
clusterPeripheral = {
|
||||||
|
'name': name+ "_" +clusterName,
|
||||||
|
'groupName': groupName+ "_" +clusterName,
|
||||||
|
'description': description+ " - " +clusterName,
|
||||||
|
'clusterName': clusterName,
|
||||||
|
'baseAddress': baseAddress,
|
||||||
|
'registers': cpRegisters,
|
||||||
|
}
|
||||||
|
device.peripherals.append(clusterPeripheral)
|
||||||
|
peripheral['subtypes'].append(clusterPeripheral)
|
||||||
|
continue
|
||||||
dim = None
|
dim = None
|
||||||
dimIncrement = None
|
dimIncrement = None
|
||||||
else:
|
else:
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче