atsam: add a length check to findPinPadMapping
Этот коммит содержится в:
родитель
0c4f0b1ebf
коммит
2540172cc5
2 изменённых файлов: 10 добавлений и 0 удалений
|
@ -136,6 +136,11 @@ var pinPadMapping = [32]byte{
|
|||
// found" (indicated by returning ok=false). The pad number is returned to
|
||||
// calculate the DOPO/DIPO bitfields of the various serial peripherals.
|
||||
func findPinPadMapping(sercom uint8, pin Pin) (pinMode PinMode, pad uint32, ok bool) {
|
||||
if int(pin)/2 >= len(pinPadMapping) {
|
||||
// This is probably NoPin, for which no mapping is available.
|
||||
return
|
||||
}
|
||||
|
||||
nibbles := pinPadMapping[pin/2]
|
||||
upper := nibbles >> 4
|
||||
lower := nibbles & 0xf
|
||||
|
|
|
@ -322,6 +322,11 @@ var pinPadMapping = [64]uint16{
|
|||
// (indicated by returning ok=false). The pad number is returned to calculate
|
||||
// the DOPO/DIPO bitfields of the various serial peripherals.
|
||||
func findPinPadMapping(sercom uint8, pin Pin) (pinMode PinMode, pad uint32, ok bool) {
|
||||
if int(pin)/2 >= len(pinPadMapping) {
|
||||
// This is probably NoPin, for which no mapping is available.
|
||||
return
|
||||
}
|
||||
|
||||
bytes := pinPadMapping[pin/2]
|
||||
upper := byte(bytes >> 8)
|
||||
lower := byte(bytes & 0xff)
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче